SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,977 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello there, I need a help about the SQL Query. Data example:
Date Amount
2024-01-11 10:15 1000
2024-01-11 11:10 2000
2024-01-12 10:16 5000
2024-01-13 11:12 4000
2024-01-13 11:18 4000
Expeceted result:
Date Amount
2024-01-11 3000
2024-01-12 5000
2024-01-13 8000
Meaning I need to group the items by date (without time) and SUM the amounts. Thank you!
For example:
select cast([Date] as date) as [Date], sum(Amount) as Amount
from MyTable
group by cast([Date] as date)
order by [Date]