Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Please help with query to get the sales value of previous and current year

$
0
0

Please help  with a query to get the previous sales and current sales from each customer from the given query, my query is not working.

With Thanks

Pol

select * from  
(Select sum(qty) as pr_qty,sum(salestotal) as pr_amt,
customer  from  sales
where catagory = 'Premium'  
and  salesdate >= #01-01-2013# 
and  salesdate < #12-31-2013#
 group by customer) previousyrs,
( Select sum(qty),sum(salestotal)  
from sales
where catagory = 'Premium'  
and customer = previous.customer
and  invdate >= #01-01-2014# );


polachan


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>