August 10, 2010 at 4:54 pm
Hi,
I am trying the following code
select user,AVG(invoiceamt) as avgtransaction,COUNT(*) as invoicecount,avg(x) as avgx from invoice
group by user
I want to include two more count functions for two more columns in the select query based on the following conditions.
1. count(vds)--vds is another column in invoice table
2. count(*) if invoiceamount<0
I am not sure how to do this. Please help.
August 10, 2010 at 10:49 pm
Please provide us some sample data to work with and the expected result. Post the same in a ready to use format so that people can give you a tested answer.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply