Quantcast
Channel: Microsoft Dynamics RMS Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4248

Find sales by department by hour or half hour

$
0
0

Can anyone help me here? I'm trying to run a TSQL view I made for Dynamics RMS to allow me to see all sales made in the past 24 hours, grouping them by 1/2 hour, and only show by department (my example, the department id is 1602).

What is happening: I'm getting a number back which is great....but it doesn't match the reports I pull in the MSFT report manager. More info: I can get it to match if I do a sum(total) on the transaction table...but that too doesn't match the MSFT report...IS there another field/table/calculation I should do to see "all sales" (not voids) over the past 24 hours? Thank you very much.

Here is the code I'm using:

SELECT        TOP (100) PERCENT DATEPART(hh, Time) AS Half_Hour, COUNT(*) AS Num_of_Sales, SUM(Total) AS Total_Sales

FROM            dbo.[Transaction]

WHERE        (TransactionNumber IN

                            (SELECT DISTINCT dbo.TransactionEntry.TransactionNumber

                              FROM            dbo.TransactionEntry WITH (NOLOCK) INNER JOIN

                                                        dbo.[Transaction] AS Transaction_1 WITH (NOLOCK) ON dbo.TransactionEntry.TransactionNumber = Transaction_1.TransactionNumber AND

                                                        dbo.TransactionEntry.ItemType <> 9 LEFT OUTER JOIN

                                                        dbo.Item WITH (NOLOCK) ON dbo.TransactionEntry.ItemID = dbo.Item.ID LEFT OUTER JOIN

                                                        dbo.Department WITH (NOLOCK) ON dbo.Item.DepartmentID = dbo.Department.ID LEFT OUTER JOIN

                                                        dbo.Category WITH (NOLOCK) ON dbo.Item.CategoryID = dbo.Category.ID

                              WHERE        (dbo.Item.DepartmentID = 1602) AND (Transaction_1.Time > '2013-12-10 00:00:00') AND (Transaction_1.Time < '2013-12-10 23:59:59')))

GROUP BY DATEPART(YEAR, Time), DATEPART(MONTH, Time), DATEPART(DAY, Time), DATEPART(HOUR, Time), DATEPART(MINUTE, Time) / 30

Thank you.


Viewing all articles
Browse latest Browse all 4248

Trending Articles



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