Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
bsharma_velcro
Contributor III
Contributor III

Passing variable in SQL query while extracting data

Hi,

I am using an SQL query to fetch previous day's data from an Oracle database. This query gives me data for just previous day. I need last 45 days worth of data on a daily basis.

Is there a way I can pass a variable for the highlighted section of the query snippet below so that I can run a loop and extract data for all the past 45 days... something like sysdate - $(vDateCount) in place of the highlighted section.

bsharma_velcro_0-1730291884381.png

Regards,

Bhaskar

Labels (1)
1 Solution

Accepted Solutions
Or
MVP
MVP

Sounds like you have a syntax issue, then. You may want to share your actual code...

View solution in original post

6 Replies
Or
MVP
MVP

Sure.

https://community.qlik.com/t5/QlikView-App-Dev/Load-data-day-by-day-using-loop/td-p/1799763

Plenty of other threads about similar requirements, so a search should help you if that one isn't precisely what you want.

 

bsharma_velcro
Contributor III
Contributor III
Author

My variable doesn't go in the where clause, but in the body of the query and subqueries within, where my variable declared in Qlik are not identified.

 

Regards,

Bhaskar

Or
MVP
MVP

What makes you say that they are not identified.,?

bsharma_velcro
Contributor III
Contributor III
Author

Because it's throwing error.

Or
MVP
MVP

Sounds like you have a syntax issue, then. You may want to share your actual code...

bsharma_velcro
Contributor III
Contributor III
Author

You are right. I had syntax and date format issue. It's working fine now.

 

Regards,

Bhaskar