Click here to Skip to main content
15,030,954 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
pls some one tell that

how to get total sale with month wise, week wise, day wise in sql server.

Pls some one tell......
Posted

1 solution

Try something like:
SQL
Get count of this month, and today:
SELECT SUM(Sales) AS TotalSales,
       SUM(CASE WHEN DATEDIFF( m, SaleDate, GETDATE() ) = 0 THEN Sales ELSE 0 END) AS SalesThisMonth,
       SUM(CASE WHEN DATEDIFF( d, SaleDate, GETDATE() ) = 0 THEN Sales ELSE 0 END) AS SalesToday
FROM MyTable
   
Comments
Maciej Los 18-Dec-13 16:36pm
   
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900