question

Sqlsimon avatar image
Sqlsimon asked

Sql join issue

Given a SQL query that joins the following two data tables, . . ., what data issue exists in the PERIOD table if after joining, total unit sales is exactly 4,394 higher thanwhat you would expect, had you just summed unit salesfrom the SALES table?

SALES Table

Country

Retailer

WeekEnd

Units

US

BestBuy

03/19/2021

4,394

US

BestBuy

03/26/2021

10,428

PERIOD Table

WeekEnd

AvgSellingPrice

Promotion_Indicator

DiscountPct

03/19/2021

$29.99

0

0%

03/19/2021

$23.99

1

20%


sqlserver2012
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Zakahme37 avatar image
Zakahme37 answered

@sqlsimon it appears that you may be joining on the dates? If so the period table has two records for 3-19 which is doubling your total when it results after join.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.