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: 
Not applicable

how to find top 1

how to find top first  value in the column through scripting.

I have a sql query i need to implement this query through script in qlikview.

i had already loaded these fields from excel.

SELECT TOP 1 [new value] FROM status_history

WHERE [defect id] = new.[defect id].

7 Replies
alexandros17
Partner - Champion III
Partner - Champion III

If you have read from excel you must use Load instead of select (this one loads from database)

so use this expression:

First 1 LOAD * resident mytable;

MayilVahanan

Hi

Try like this

First 1 Load NewValue;

SELECT [new value] FROM status_history

WHERE [defect id] = 34;

or

You can use directly like this

SQL SELECT TOP 1 [new value] FROM status_history

WHERE [defect id] = new.[defect id];

but new.[defect id] is referring any other table???

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
its_anandrjs
Champion III
Champion III

You can directly use SQL query as

SQL SELECT TOP 1 [new value] FROM status_history

WHERE [defect id] = new.[defect id].

sasikanth
Master
Master

HI

Try some thing like this

SELECT TOP 1 *   FROM status_history

WHERE [defect id] = new.[defect id].

you can replace 1 with any number

amit_saini
Master III
Master III

Hi Nishika,

Try this:

SELECT TOP 1 column_name FROM table_name
ORDER BY column_name ASC;

Thanks,

AS

Not applicable
Author

The error is odbc connection failed .

I had already loaded the column from my excel sheet and i need to perform this sql query in qlikview by implementing it through script I don't want to connect it with database  from where i fetched the sql query.

PradeepReddy
Specialist II
Specialist II

If u want to fetch  Top N values

1)  Irrespective of order,

     SELECT TOP N Column_Name FROM status_history

      WHERE [defect id] = new.[defect id]

2) In Order, i.e  Max N or Min N records,

     SELECT TOP N Column_Name FROM status_history

      WHERE [defect id] = new.[defect id]

     Order by Column_Name ASC/DESC