SQL Query for Offline & Online sales table.

Fareed Shaik 81 Reputation points
2023-12-29T12:25:28.9+00:00

I have 2 tables as shown below Table 1 and Table -2

image

User's image

I need an output as shown below by joining Table-1 and Table-2

Please help in getting join Query in SQL.

User's image

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
SQL Server | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Erland Sommarskog 130.9K Reputation points MVP Volunteer Moderator
    2023-12-29T22:45:03.7133333+00:00
    SELECT isnull(a.Date, b.Date) AS Date, isnull(a.ID, b.ID) AS id, isnull(a.area, b.Area) AS area, a."Sales - Store", b."Sales - Online"
    FROM  table_1 a
    FULL JOIN table_2 b ON a.Date = b.Date
                       AND a.ID = b.ID
                       AND a.area = b.area
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.