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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
rittermd
Master
Master

Script Coding Question

I was provided with this standard sql code by a developer and am having trouble figuring out how to get it setup in QS script to work properly.  Any advice would be greatly appreciated.

SELECT tp.sessionkey, COUNT(*)

FROM transactions te

JOIN transactions tp ON tp.k = te.parentkey

WHERE te.srcfile LIKE '2018-05-09%'

AND te.worktype IN ('envelope')

GROUP BY tp.sessionkey ;


Thanks

1 Solution

Accepted Solutions
Anonymous
Not applicable

Try adding a name for the count column:

SELECT tp.sessionkey, COUNT(*) AS NrSessions

FROM transactions te

JOIN transactions tp ON tp.k = te.parentkey

WHERE te.srcfile LIKE '2018-05-09%'

AND te.worktype IN ('envelope')

GROUP BY tp.sessionkey ;

View solution in original post

5 Replies
JustinDallas
Specialist III
Specialist III

What's the issue?  Are you trying to put the SQL in a load statement? i.e

Transactions:

LOAD *

;

SQL SELECT tp.sessionkey, COUNT(*)

FROM transactions te

JOIN transactions tp ON tp.k = te.parentkey

WHERE te.srcfile LIKE '2018-05-09%'

AND te.worktype IN ('envelope')

GROUP BY tp.sessionkey

;

Or is something not parsing correctly.

vishsaggi
Champion III
Champion III

What is the error your are getting here? Did you connect to your correct database?

rittermd
Master
Master
Author

I get a message that blank field name is not allowed

Anonymous
Not applicable

Try adding a name for the count column:

SELECT tp.sessionkey, COUNT(*) AS NrSessions

FROM transactions te

JOIN transactions tp ON tp.k = te.parentkey

WHERE te.srcfile LIKE '2018-05-09%'

AND te.worktype IN ('envelope')

GROUP BY tp.sessionkey ;

rittermd
Master
Master
Author

That was it.  Thank you