Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
jtworks
Contributor II
Contributor II

Qlik script version of T-SQL

I want the Qlik script equivalent of :

SELECT TOP 1 [City]
, SUM([Amount]) As Amount
FROM Table
GROUP BY [City]
ORDER BY SUM(Amount) DESC;

Labels (1)
4 Replies
anat
Master
Master

table1:

select  City,Amount from table;

noconcatenate

table2:

load city,sum(Amount) resident table1 group by city order by 2 desc;

drop table table1;

jtworks
Contributor II
Contributor II
Author

Thanks for your response. This however did not work, it is also missing in TOP 1 clause. I just want to have the City with the highest sales.

Or
MVP
MVP

Have a look at e.g.

https://community.qlik.com/t5/QlikView-App-Dev/Get-Top-N-Records-from-a-Table-based-on-Group-by/td-p...

Similar question, so you should be able to adapt that to your scenario.

 

jtworks
Contributor II
Contributor II
Author

Thanks for the reference. It is closer but it is listing all other states. I just want only the state with highest sales.