Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

andreyfcdk91
New Contributor III

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

Re: Quantity work conditions in SQL query

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

];

andreyfcdk91
New Contributor III

Re: Quantity work conditions in SQL query

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
Honored Contributor III

Re: Quantity work conditions in SQL query

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

Re: Quantity work conditions in SQL query

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;

prma7799
Honored Contributor III

Re: Quantity work conditions in SQL query

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);