Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics RMS (Archived)

SQL query for sales does not match Daily Sales by Register Report

Posted on by

i wrote the following query against my Headquarters database to determine sales:

SELECT     StoreID, RegisterID, Sales
FROM         Batch
WHERE     (OpeningTime > CONVERT(DATETIME, '2014-05-05 12:00:00', 102)) AND (OpeningTime < CONVERT(DATETIME, '2014-05-06 11:59:59', 102))
ORDER BY StoreID,RegisterID

If I run a Daily Sales by Register Report in HQ the sales in the Today column don't match the sales from the Batch table. Does anyone know why these sales figures don't match up?

*This post is locked for comments

  • Suggested answer
    Hat Mann Profile Picture
    Hat Mann on at
    RE: SQL query for sales does not match Daily Sales by Register Report

    Thanks for the reply CHAZH345. You were correct, I needed to add the SUM of the Returns table as it is a negative number. The sales figures now match.

    SELECT(SUM(Sales))as "Sales",(SUM(Returns))as "Returns", (SUM(Sales)+ SUM(Returns)) as "Total Sales"

    FROM         Batch

    WHERE     (OpeningTime > CONVERT(DATETIME, '2014-05-05 12:00:00', 102)) AND (OpeningTime < CONVERT(DATETIME, '2014-05-06 11:59:59', 102))

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SQL query for sales does not match Daily Sales by Register Report

    If you are comparing Transaction and TransactionEntry to Batch Sales total, it will not add up until you subtract Voucher item sales and returns from the SUM of the line items.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans