cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Queries Logical Operator Issue

former_member193552
Participant
0 Kudos

I have tow queries. Query 1 does not give right result where 2 gives right result.. It is the way I am applying filter on Hub field. Can someone please explain what is wrong with hub filter in Query 2.

First value of hub (GRECAR) belongs to Division value LA and second value of Hub ( VE) belongs to Division Value LV

--Wrong Query

SELECT "CalMonth", SUM("WorkingCapitalPercentSales") AS "WorkingCapitalPercentSales_SUM" FROM "_SYS_BIC"."com.colpal.xc.brof.Backend.Finance/CV_WCPercentSales" WHERE ("Division" = 'LA' or "Division" = 'LV') AND ( "Hub" <> 'GRECAR' or "Hub" <> 'VE') AND "CalYear" = '2018'

GROUP BY "CalMonth" ORDER BY "CalMonth" ASC

--Correct Query SELECT "CalMonth", SUM("WorkingCapitalPercentSales") AS "WorkingCapitalPercentSales_SUM" FROM "_SYS_BIC"."com.colpal.xc.brof.Backend.Finance/CV_WCPercentSales" WHERE ("Division" = 'LA' or "Division" = 'LV') AND ( "Hub" <> 'GRECAR') AND ("Hub" <> 'VE') AND "CalYear" = '2018'

GROUP BY "CalMonth" ORDER BY "CalMonth" ASC

Accepted Solutions (0)

Answers (1)

Answers (1)

SergioG_TX
Active Contributor
0 Kudos

I am not sure what you consider wrong vs right, however, I believe you need to group your Division and Hub query based on the where condition parts.

are you trying to display data within those divisions but not within the Hubs?

or within the divisions and only specific hubs per division -- that is how your desired output may need to be approached