July 11, 2003 at 2:00 pm
I need to broken down the report by regions and sales. I know how to get this done in Access, but SQL is a bit differcult to tackle. Anyone help would be welcome.
thanks
-------sales #, sales amounts
Region1
Region2
Region3
-------total # of Sales, Totals of $
July 13, 2003 at 3:01 am
Is this what you want?
Select region, sum(salesAmt) from MySalesTables
Group By region
Compute SUM(SUM(SalesAmt))
One word of warning.
If you are using the result for client side usage. you may get an error.
It is because you are getting 2 resultsets.
G.R. Preethiviraj Kulasingham
Chief Technology Officer.
Softlogic Information Systems Limited,
14 De Fonseka Place,
Colombo 05.
Sri Lanka.
Cheers,
Prithiviraj Kulasingham
http://preethiviraj.blogspot.com/
July 14, 2003 at 8:35 am
Thanks Preethi,
I was thinking in the line of this...
select *, TotalMonth = Region1 + Region2 + Region3 + Region4
from
(
Select
Sum(Case Region When 1 Then (xvalues) Else 0 End) As Region1,
Sum(Case Region When 2 Then (xvalues) Else 0 End) As Region2,
Sum(Case Region When 3 Then (xvalues) Else 0 End) As Region3,
Sum(Case Region When 4 Then (xvalues) Else 0 End) As Region4
from invasset O
where status =3 group by Region
)
July 14, 2003 at 11:28 am
You can try this if you want a cross tab like result
Select
Sum(Case Region When 1 Then (xvalues) Else 0 End) As Region1,
Sum(Case Region When 2 Then (xvalues) Else 0 End) As Region2,
Sum(Case Region When 3 Then (xvalues) Else 0 End) As Region3,
Sum(Case Region When 4 Then (xvalues) Else 0 End) As Region4
Sum(xValues) as Total
From
invasset O
where status =3
G.R. Preethiviraj Kulasingham
Chief Technology Officer.
Softlogic Information Systems Limited,
14 De Fonseka Place,
Colombo 05.
Sri Lanka.
Cheers,
Prithiviraj Kulasingham
http://preethiviraj.blogspot.com/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply