Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Quantity work conditions in SQL query

Good day!

I have simple table:

   

 

Field1Field2Field3Field4
1201254
23744432
435556445
12435435344
122244435

My task is to write SQL select query, which must get me rows, for which quantity of worked conditions=2

and only those records, for which quantity of worked below conditions=2:

1. Field1>Field2

2. Field3=444

3. Field4>32

In result i need get only first 2 records:

Field1Field2Field3Field4
1201254
23744432

Thanks.

5 Replies
Anil_Babu_Samineni

May be this? I am not sure why you want Field3 - 12 in the result, Because we are filtering the only 444 from that table?

Load Field1, Field2, Field3, Field4 Where Field1 > Field2 and Field3 = 444 and Field4 > 32;

LOAD * Inline [

Field1, Field2, Field3, Field4

12, 0, 12, 54

23, 7, 444, 32

43, 55, 5, 6445

12, 435, 43534, 4

122, 2, 444, 35

];

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

Thanks.

But it must be not scripting code from QV. I need SQL query.

Query must check each records and quantity conditions for each of them which are working.

If quantity of working conditions for some record =2, it must be shown in result table.

prma7799
Master III
Master III

Please give proper name for your field then it will help us to give reply.

Anil_Babu_Samineni

I am sorry, We are in Qlik Forum. Move to DB Forum

FYI, This should work in SQL Engine

SELECT Field1, Field2, Field3, Field4 From TableName Where Field1 > Field2 and Field3 = 444 and Field4 > 32;

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
prma7799
Master III
Master III

Field1 Field2 Field3 Field4
12 0 12 54
23 7 444 32

Thanks.

For this you can simply write

select  Field1,Field2,Field3,Field4

from tablename

where Field1 in (12,23);