September 10, 2008 at 1:22 pm
I have written many simple queries but I have to run them sequentially. How can I run two questions in one query?
For example:
Give me the total of sales in June
Give me the total of sales in July
I would like the answer thus:
Sales
June
July
I hope this makes sense. Thank you in advance.
September 10, 2008 at 1:29 pm
Could you give us more info please? Maybe give a couple of the queries you want to combine, show what they return now and show what you want them to return.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 10, 2008 at 1:30 pm
select
datename(mm, SalesDate) as Month,
sum(TotalSale) as TotalSales
from
dbo.SalesOrder
group by
datename(mm, SalesDate)
order by
datepart(mm, SalesDate);
Something like that??
😎
September 10, 2008 at 2:22 pm
Thank you.
I'll get back with a more detailed example.
September 10, 2008 at 2:25 pm
Thank you.
I'll get back with a more detailed example.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply