barnettjacob
IS-IT--Management
Hi, I've got the following query which I'm trying to streamline to bring through summarized data. The problem is that in our database all the sales are recorded as a 'long' date with the time which means I am struggling to summarize by day. I've got the code to reformat the date which works well but I can't get that to drive the 'group by' which kind of defeats the object!
Any help would be appreciated.
Jacob
Any help would be appreciated.
Jacob
SQL:
select
p.Analysis1Code,
p.Supplier1,
s.branchCode,
(SELECT CONVERT(VARCHAR(10), Saledate, 103)) as date,
sum(quantity),
sum(fcextendednetamount-fcextendedtaxamount) as 'FCNetSales',
sum(grossprofitalternategp) as 'AltGP',
from eee..vwsaleline_gp s
join eee..product p on p.productcode = s.productcode
where saledate >= '07/01/10'
group by (SELECT CONVERT(VARCHAR(10), Saledate, 103)), p.Analysis1Code, p.Supplier1, s.branchCode
order by s.BranchCode, s.saledate, p.Analysis1Code,p.Supplier1