For those interested in the relationship between atmospheric CO2 and fossil fuels, you can use WolframAlpha to compose balanced chemical equations. A breakdown of average composition for produced natural gas can be found here.
Consider the dominant hydrocarbon present in natural gas, methane. Alpha shows that for each methane molecule burned, one CO2 molecule is created along with 2 water molecules. (Methane, CO2, and water vapor are all greenhouse gases.) One reason we have a growing CO2 concentration in the atmosphere is, of course, because we burn methane like crazy to get the other output of the reaction: energy (890 kJ/mole, an exothermic reaction).
The combustible part of crude oil is dominated by naphthenes, a complicated family of long-chain hydrocarbon compounds. But taking napthene itself as typical, Alpha shows that burning naphthene results in 10 CO2 molecules. Generally, more CO2 is generated per molecule as the hydrocarbon chain gets longer. It has to be this way, because the carbon atom in each CO2 molecule is coming from a carbon atom in the burned molecule. Burning C10H8 (naphthene) gives 10 CO2; burning C22H16 (name?) gives 22 CO2; and so on.
All this leads to a general statement so often bandied about: gas is much more CO2-friendly than oil. But oil has its advantages, too. It packs more of a whallop -- burning the same number of methane and naphthene molecules, the naphthene releases 5.7 times as much energy. In other words, to get the same energy from burning gas (methane) and oil (naphthene) would require burning 5.7 times as much gas (in a molecular sense). But the CO2 score for gas (5.7 CO2) still comes out ahead of oil (10 CO2).
We have not mentioned coal so far, but let me just say it is hard to even put a chemical formula on it. One approximate chemical formula is C135H96O9NS (ppt file, slide 5). From what was said above, we know that burning one molecule of coal will generate 135 CO2 molecules. It would be nice to do the equal-energy comparison as we did with gas and oil, but even Alpha comes up empty on energy release for this reaction. But I think we can get an approximate answer.
Burning 1 kg of gas (methane) gives 2.74 kg of CO2 and 55.7 mJ energy
Burning 1 kg of oil (naphthene) gives 3.43 kg of CO2 and 40.3 mJ energy
Burning 1 kg of coal (C135H96O9NS) gives 2.58 kg of CO2 and 23.5 mJ energy (use 1 kilogram = 0.00110231131 short tons in this coal calculator)
On the basis of gCO2/mJ, fossil fuel CO2 output is:
where these numbers represent grams of CO2 created per megajoule of energy released by combustion (approximately). Normalizing this to coal, the following chart summarizes the result:
That is a big CO2 difference per unit energy generated. It says, for example, that a coal-fired electrical generation plant converted to natural gas reduces CO2 output by about 55%. The question then becomes the cost of coal-to-gas conversion vs the cost of say, carbon capture and sequestration. But cost can be more than just money, for large-scale subsurface injection and storage of CO2 there are also the issues of public acceptance, MVA, pore-space ownership, etc.