NEW YORK (CNN/Money) -
We bought 100 shares of AOL at $32.96 a share and later bought an additional 100 shares at $9.99 apiece. Can we sell the first 100 shares we bought and take a tax loss?

-- Jerry & Martha Schuh, Las Vegas, Nev.

Ironic, isn't it, how within just a couple of years AOL (which, by the way, is the corporate parent of this Web site) has gone from a stock renowned for generating stellar gains to one that's become an example for how to take a tax loss? Ah, how the mighty have fallen.

Can you imagine how Ted Turner, the retiring vice chairman of AOL, must feel? Last week, he unloaded 60 million shares of AOL for a reported $784 million, or $13.07 a share. Back in AOL's glory days, those shares would have been worth $5.6 billion. Don't feel too sorry for Ted, though. He still owns another 45 million or so shares, which are worth about $598 million at AOL's recent price of $13.29 a share. So he'll muddle through somehow.

Here's how it works

But back to your question. Sure, you can sell the AOL shares you bought for $32.96 and take a tax-deductible loss on them. Here's how the process works.

A stock like AOL bounces around a lot from day to day, but let's assume you sell your shares for $13.30, which is in the ballpark for AOL's recent trading range. That sale would give you a capital loss of $19.66 a share, or $1,966 for 100 shares. (For simplicity's sake, we'll ignore your brokerage commissions for both buying and selling, although you should include them because they'll increase the size of your deductible loss.)

So the question becomes: What do you do with that capital loss? What can you deduct it against?

The first thing you have to determine is whether you have a short-term capital loss (that is, a loss on a security held for a year or less) or a long-term capital loss (a loss on a security held longer than a year). The last time that AOL traded at the price you paid -- $32.96 a share -- was at the end of 2001. So that means you've held the stock more than a year, which means you have a long-term capital loss.

Once you've established your capital loss, you must first offset it against any capital gains you have for the year you sold your AOL shares.

But which losses to offset?

Ideally, you would like to offset your long-term capital loss against a short-term capital gain. Why? Because short-term capital gains are taxed at ordinary income rates, which max out this year at 38.6 percent, while long-term capital gains rates can go no higher than 20 percent.

Let's say, for example, that you had sold another stock you owned for less than a year for a profit of $1,966. Normally, you could owe as much as $759 in tax on that profit for this tax year ($1,966 x 38.6 percent). By applying your long-term capital loss to that profit, however, you wipe it out, saving yourself the $759.

By contrast, if you had sold a stock that you'd held longer than a year for the same $1,967 profit, the maximum you could owe in tax would be $393 ($1,966 x 20 percent). Applying your $1,966 loss to that gain would save you money, but not as much as applying the loss to a short-term capital gain.

Unfortunately, we can't decide on our own how to pair capital losses and capital gains. The tax code sets some rules about that. And what the code says is that when matching capital gains and losses, you must first pair long-term losses against long-term gains, and short-term against short-term gains. Only after doing that can you mix short-term and long-term gains and losses.

There is some flexibility to the rules

That said, however, you do have at least some control over which gains and losses you create. For example, let's say you're thinking of selling your AOL shares for a long-term capital loss and you have some other securities you're considering selling for a gain. From a tax point of view, it would make sense to sell securities that would generate a short-term capital gain rather than ones that would generate a long-term capital gain. (Taxes alone, of course, should not dictate your investing decisions.)

If you still have a loss after going through this process -- that is, your capital loss exceeds your long- and short-term capital gains -- you can use the remaining loss to offset up to $3,000 of ordinary income, such as that from wages, interest, dividends, and pensions. And if that doesn't soak up your loss, you get to carry it forward indefinitely into the future until you've used it up.

One more thing: If you do sell stock for a loss, you want to be sure you don't violate of the IRS's "wash sale" rules. Essentially, these rules disallow all or part of your loss if you buy or sell the same security or a "substantially identical" one 30 days before or 30 days after the sale.

Just to be sure you're not running afoul of any of the government's many rules relating to securities sales and tax losses, you'll probably want to go to the IRS Web site's menu of publications and download a copy of Publication 550: Investment Income and Expenses. There, in all its detailed splendor, you'll find the rules governing virtually every permutation you can think of when it comes to booking tax losses. Just don't read it before operating heavy machinery.