Thanks. Looks this is what I've been looking for. I don't quite understand your table definition though. Does "WHERE inputs IS NULL" restrict result only to coin-generation transactions?
It eliminates spent outputs. The total value of unspent outputs should equal the total BTC in circulation (as it does).
The LEFT JOIN matches each output with the input that spent it. If inputs IS NULL for a row, then the output is unspent.
I intend to release my getblock-to-SQL script at some point in the far future, since it allows easy access to stats like this. It's much too messy right now, though.
I hope you can consider providing these service to function as an early warning system for the bitcoin network.