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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sarsukanth
Contributor III
Contributor III

How to use Group By in Qlik Sense Scripting

Hi All,

I want to convert the below PL/SQL query in to Qlik Sense Script and get the result, I am new to Qlik Sense so please help me here.

Select
p.party_id
,p.addr_line_1
,p.addr_line_2
,p.city,p.state
,p.postal_cd_prim
,p.status_code
from party_address p
where p.status_code = 'A'
group by
p.party_id
,p.addr_line_1
,p.addr_line_2
,p.city,p.state
,p.postal_cd_prim
,p.status_code
having count(distinct p.addr_id) > 1

 

Thank you,

Raghu

Thank you,
Raghu
1 Reply
Dalton_Ruer
Support
Support

You can run native SQL commands directly. Below "MyTableName" would be the name you want in Qlik for the table. Then simply use SQL keyword to run any native select command. 

MyTableName:

SQL Select p.party_id
,p.addr_line_1
,p.addr_line_2
,p.city,p.state
,p.postal_cd_prim
,p.status_code
from party_address p
where p.status_code = 'A'
group by
p.party_id
,p.addr_line_1
,p.addr_line_2
,p.city,p.state
,p.postal_cd_prim
,p.status_code
having count(distinct p.addr_id) > 1;

If you want to create nicer names for you fields in Qlik you can use the LOAD syntax like this

MyTableName:

Load p.party_id as "Party ID",

p.addr_line_1 as "Address Line 1", 

p.addr_line_2 as "Address Line 2", 

etc

p.status_code as "Status Code";

SQL Select p.party_id
,p.addr_line_1
,p.addr_line_2
,p.city,p.state
,p.postal_cd_prim
,p.status_code
from party_address p
where p.status_code = 'A'
group by
p.party_id
,p.addr_line_1
,p.addr_line_2
,p.city,p.state
,p.postal_cd_prim
,p.status_code
having count(distinct p.addr_id) > 1;