>>This can be done in a single command, more or less like this:
>
>
>>select ItemName,;
>> sum(iif(month(DateField) = 1, ValueField, $0)) as Jan,;
>> sum(iif(month(DateField) = 2, ValueField, $0)) as Feb,;
>> ...
>
>Thanks Hilmar,
>
>I'm using VFP to connect to an SQL database via ODBC so I can't use the IIF() because it's not understood by the ODBC connect. Ultimately, once I figure out how to write this SQL (that's compatible with MSQ 6.5), I then need to move it to Excel & MS Query to pull the data directly into the spreadsheet. The people that need this data don't have a copy of VFP and I don't want to get involved in creating and distributing EXE's.
>
>Thanks,
>Robert
Sorry, I don't know how to do this in SQL Server. I am sure you can use the same basic principle, but the functions, of course, are different.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)