zeeshanmbutt
Programmer
Hi All,
I have a table called Table1 with the following fields and types.
ZoneName(nvarchar),OutletID(nvarchar),CatID(nvarchar),SaleDate(datetime),TotalUnits(decimal),DollarSales(decimal),Profit(decimal).
Using the above Table1 I want to get the Sum(TotalUnits),Sum(DollarSales),Sum(Profit) per zonename, per saledate, and per catid, where;
its same ZoneName, same CatID, and same OutletID
That is in my select Query i want the following fields:
ZoneName,CatID,SaleDate,Sum(TotalUnits),Sum(DollarSales),Sum(Profit)
And the join should be on the following fields:
ZoneName
CatID
OutletID
I guess I would need a self join with a sub query.
How can I acieve this in SQL?
Please let me know.
Thanks a million.....
I have a table called Table1 with the following fields and types.
ZoneName(nvarchar),OutletID(nvarchar),CatID(nvarchar),SaleDate(datetime),TotalUnits(decimal),DollarSales(decimal),Profit(decimal).
Using the above Table1 I want to get the Sum(TotalUnits),Sum(DollarSales),Sum(Profit) per zonename, per saledate, and per catid, where;
its same ZoneName, same CatID, and same OutletID
That is in my select Query i want the following fields:
ZoneName,CatID,SaleDate,Sum(TotalUnits),Sum(DollarSales),Sum(Profit)
And the join should be on the following fields:
ZoneName
CatID
OutletID
I guess I would need a self join with a sub query.
How can I acieve this in SQL?
Please let me know.
Thanks a million.....