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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Smeenakshi23
Creator II
Creator II

Two Different condition in Qlikview SQL

Hello,

I am developing a Query using some requirements

in select statement i am giving Number,date,department,Type etc..Also I am summing up sum(sales) in select statement.. I need to add the below two conditions in my query. How to implement it in SQL statement.

Condition :

1) total amount(sales) with TYPE = s equals zero
2)total amount(sales) with TYPE = y is less than zero


sample code :

Select Number,sum(sales) as Total_Sales, Type, Date, Department

from ...// pulled necessary table//
where....// date condition and link fields are given here//

groupby Number,sales, Type, Date, Department;

can you please suggest.

Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda
MVP
MVP

Select a.*
from (Select Number,sum(sales) as Total_Sales, Type, Date, Department

from ...// pulled necessary table//
where....// date condition and link fields are given here//

group by Number,sales, Type, Date, Department )a
Where (a.Total_Sales=0 and Type='s') or (a.Total_Sales<0 and Type='y')

View solution in original post

3 Replies
jwjackso
Specialist III
Specialist III

I think a Preceding Load statement  would work.

 

sample code :

Load *

where (Total_Sales = 0 and TYPE = 's') or (Total_Sales < 0 and TYPE = 'y');

SQL Select Number,sum(sales) as Total_Sales, Type, Date, Department

from ...// pulled necessary table//
where....// date condition and link fields are given here//

groupby Number,sales, Type, Date, Department;

Kushal_Chawda
MVP
MVP

Select a.*
from (Select Number,sum(sales) as Total_Sales, Type, Date, Department

from ...// pulled necessary table//
where....// date condition and link fields are given here//

group by Number,sales, Type, Date, Department )a
Where (a.Total_Sales=0 and Type='s') or (a.Total_Sales<0 and Type='y')
Smeenakshi23
Creator II
Creator II
Author

Thanks a lot