Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to implement sql query in the qlikview scripting

how to implement sql query

6 Replies
tresesco
MVP
MVP

You can use the same sql query as it is in qv and fetch using 'SQL' command data like:

SQL <your query>;

Not applicable
Author

No it is not working it is showing error

tresesco
MVP
MVP

It works. If you are getting error, it has to be something with your approach. What is the error message you are getting?

jagan
Luminary Alumni
Luminary Alumni

Hi,

You need to give ; before the SQL keyword instead of comma.

Try like this

LOAD

*;

SQL SELECT tab.*, Round((DateDiff("h",startdate,enddate)/24)-DateDiff("ww",startdate,enddate,1)-DateDiff("ww",startdate,enddate,7),2) AS durationdays, Round((DateDiff("n",startdate,enddate))-DateDiff("ww",startdate,enddate,1)*1440-DateDiff("ww",startdate,enddate,7)*1440,2) AS durationmin

FROM (SELECT [defect id], [New Value], [old value], [Change Date/Time] AS startdate, (SELECT TOP 1 [change date/time] FROM status_history next WHERE [defect id] = new.[defect id] and [Change Date/Time] > new.[Change Date/Time]  and [old Value]=new.[New Value] order by [Change Date/Time]) AS enddate, (SELECT TOP 1 [new value] FROM status_history next WHERE [defect id] = new.[defect id] and [Change Date/Time] > new.[Change Date/Time] and [old Value]=new.[New Value] order by [Change Date/Time]  ) AS nextValue FROM status_history AS new WHERE [changed field]='BG_STATUS')  AS tab;

Regards,

Jagan.

Not applicable
Author

i need write the script for it in qlikview no connection from sql.

its_anandrjs

As far as the concern about the excel data load use the ODBC connection for excel otherwise a way that you can load directly data from the excel files.

Load Fields...

From Location;