Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 480

How to SUM all values from a MONEY column with the same DATE into one row for that date

$
0
0

I have tables I need to get combined (SUM of) daily production values on one row for each date to calculate total production for that department for each unique date. My t-SQL code below returns separate rows, as shown in the results that I have pasted below the query.

USE CPRCREATE TABLE [dbo].[CPR_TotalDailyHygieneProd1845] (    [HygienistReportDate] [DATETIME] NULL,    [TotalDailyHygieneProd] [MONEY] NULL)Insert INTO dbo.CPR_TotalDailyHygieneProd1845 (    HygienistReportDate,    TotalDailyHygieneProd)SELECT DISTINCT     CAST(dbo.tHygienistStats.ReportDate AS DATE),    SUM(dbo.tHygienistStats.DailyHygieneProd) AS TotalDailyHygieneProdFROM dbo.tHygienistStatsWHERE dbo.tHygienistStats.PracticeID = '1845'    GROUP BY     dbo.tHygienistStats.ReportDate,    dbo.tHygienistStats.DailyHygieneProdGO
HygienistReportDate TotalDailyHygieneProd2024-07-19 00:00:00.000 549.002024-07-19 00:00:00.000 1291.002024-07-19 00:00:00.000 1351.002024-07-19 00:00:00.000 1501.002024-07-18 00:00:00.000 909.002024-07-18 00:00:00.000 1092.002024-07-18 00:00:00.000 1228.002024-07-18 00:00:00.000 1342.002024-07-18 00:00:00.000 1518.002024-07-17 00:00:00.000 0.002024-07-17 00:00:00.000 953.002024-07-17 00:00:00.000 1223.002024-07-17 00:00:00.000 1431.002024-07-17 00:00:00.000 1783.00

Please see my examples that I have pasted above.


Viewing all articles
Browse latest Browse all 480

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>