April 28, 2004 at 9:43 am
Hi
I need to create an excel report from the next table (SQL 2000) :
Columns are like orderlines : client, article, quantity
What do I need ?
Client - Article - Sum (per article/client) where quantity > 0 - Sum (per article/client) when quantity > 0
So like :
X - DVD - 3 (=Delivered) - -2 (Returned)
Y - DVD2 - 3 - -1
Can ayone help me ?
Much obliged.
Jeff
JV
April 28, 2004 at 10:07 am
select
client,
article,
sum(case when quantity > 0 then 1 end) delivered,
sum(case when quantity < 0 then 1 end) returned
from #temp
group by client, article order by 1
You can DTS into Excel, or you can code in Excel VBA. If in VBA, try using the CopyFromRecordset method of the range object to simply paste your ADO recordset into the worksheet.
[font="Courier New"]ZenDada[/font]
April 28, 2004 at 10:11 am
oops i meant:
select
client,
article,
sum(case when quantity > 0 then quantity else 0 end) delivered,
sum(case when quantity < 0 then quantity else 0 end) returned
from #temp
group by client, article order by 1
[font="Courier New"]ZenDada[/font]
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply