Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
QFanatic
Creator
Creator

Assist with join code please

Hello

I have a transaction table (that is currently missing one day's data for March - the 18th) and a Calendar table.

Code looks like this...

Dates_t:
select  req_date
   from
Date_Dim_Table where req_date between 20200301 and 20200331 (this returns 31 rows - correct)

Then I want to join to Trans table

Volumes:
LEFT join (Dates_t) Load *;

SELECT
  log_date as req_date
  ,count(1) as hour_volume
FROM
Trans_Table
   where log_date between 20200301 and 20200331
group by 1

 

I want the result to have Zero for hour_volume for the 18th - since there is no data, it shouldnt just be omitted from the Table.

I figured using a LEFTJoin would work, bit it doesnt .

Any assistance please. Thank you

Labels (1)
1 Solution

Accepted Solutions
MayilVahanan

Hi

Try like below

Dates_t:
select  req_date
   from
Date_Dim_Table where req_date between 20200301 and 20200331 (this returns 31 rows - correct)

Then I want to join to Trans table

Volumes:
LEFT join (Dates_t) Load *;

SELECT
  log_date as req_date
  ,count(1) as hour_volume
FROM
Trans_Table
   where log_date between 20200301 and 20200331
group by 1;

NoConcatenate

FinalTable:
Load req_date, Alt(hour_volume, 0) as B Resident Dates_t;

DROP Table Dates_t;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

2 Replies
MayilVahanan

Hi

Try like below

Dates_t:
select  req_date
   from
Date_Dim_Table where req_date between 20200301 and 20200331 (this returns 31 rows - correct)

Then I want to join to Trans table

Volumes:
LEFT join (Dates_t) Load *;

SELECT
  log_date as req_date
  ,count(1) as hour_volume
FROM
Trans_Table
   where log_date between 20200301 and 20200331
group by 1;

NoConcatenate

FinalTable:
Load req_date, Alt(hour_volume, 0) as B Resident Dates_t;

DROP Table Dates_t;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
QFanatic
Creator
Creator
Author

Thank you - forgot about ALT