Author |
Topic |
knocknaboula
Starting Member
3 Posts |
Posted - 2014-08-21 : 05:53:40
|
WHERE BCti.exchangeId = 13 OR BCti.exchangeId = 14 OR BCti.exchangeId = 18 OR BCti.exchangeId = 256 OR BCti.exchangeId = 395 OR BCti.exchangeId = 398 OR BCti.exchangeId = 405 OR BCti.exchangeId = 477 OR BCti.exchangeId = 496 OR BCti.exchangeId = 846 OR BCc.countryId = 37 )-- Canadian exchange id'sAND (BCct.companyTypeId = 1 OR BCct.companyTypeId = 4 OR BCct.companyTypeId = 13)-- 'A' or 'B'AND (BCs.primaryFlag = 1 AND BCs.securitySubTypeId = 1)AND (BCti.tradingItemStatusId = 15 OR BCti.tradingItemStatusId = 13 OR BCti.tradingItemStatusId = 10 OR BCti.tradingItemStatusId = 3 OR BCti.tradingItemStatusId = 5) AND (BCti.tradingItemStatusId = 15 OR BCti.tradingItemStatusId = 13 OR BCti.tradingItemStatusId = 10 OR BCti.tradingItemStatusId = 3 OR BCti.tradingItemStatusId = 5)AND BCti.primaryFlag = 1 AND (BCti.tradingItemStatusId = 15 OR BCti.tradingItemStatusId = 13 OR BCti.tradingItemStatusId = 10 OR BCti.tradingItemStatusId = 3 OR BCti.tradingItemStatusId = 5)MY Problem is that some rows I need to return do not have a BCti.Primaryflag = 1 (the only options are 1 or 0). they do meet all the other where conditions.I am not sure how I can incorporate them. Would this be done through a case statement? I need to keep the BCti.Primaryflag = 1 condition in there or I will gets multiple records for each company. |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-21 : 07:45:47
|
quote: Originally posted by knocknaboula MY Problem is that some rows I need to return do not have a BCti.Primaryflag = 1 (the only options are 1 or 0). they do meet all the other where conditions.I am not sure how I can incorporate them. Would this be done through a case statement? I need to keep the BCti.Primaryflag = 1 condition in there or I will gets multiple records for each company.
These two requirements contradict each other and are not logically possible to achieve together. Please explain further what you are looking for. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2014-08-21 : 08:14:25
|
How do you identify that "some rows"? Too old to Rock'n'Roll too young to die. |
|
|
knocknaboula
Starting Member
3 Posts |
Posted - 2014-08-21 : 08:31:43
|
What is happening at the moment is that I am getting rows from BCTi where BCti.exchangeid not in (13,14,18,256,395,398,405,477,496,846) because they have a Primaryflag of 1 and they also meet the other where conditions. (They are being pulled in because they have Bcc.countryid = 37 which is correct).So in affect what I want is where BCti.Primaryflag = 1 and exchangeid Not in (13,14,18,256,395,398,405,477,496,846) to then ignore the primary flag = 1 and return a row where the BCti.exchangeid is IN (13,14,18,256,395,398,405,477,496,846) |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-21 : 08:45:51
|
so...why not this:WHERE ((BCti.Primaryflag = 1 and exchangeid Not in (13,14,18,256,395,398,405,477,496,846)) OR (exchangeid in (13,14,18,256,395,398,405,477,496,846))) |
|
|
knocknaboula
Starting Member
3 Posts |
Posted - 2014-08-21 : 09:00:17
|
The problem is that where BCti.Primaryflag = 1 they may also be exchangeid is IN (13,14,18,256,395,398,405,477,496,846) and I only want to start looking at BCti.primaryflag = 0 where the above condition on primaryflag is not true but there are rows for this company in exchangeid = (13,14,18,256,395,398,405,477,496,846). |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-21 : 09:06:27
|
quote: Originally posted by knocknaboula The problem is that where BCti.Primaryflag = 1 they may also be exchangeid is IN (13,14,18,256,395,398,405,477,496,846) and I only want to start looking at BCti.primaryflag = 0 where the above condition on primaryflag is not true but there are rows for this company in exchangeid = (13,14,18,256,395,398,405,477,496,846).
OK -- Add one more thing:WHERE ((BCti.Primaryflag = 1 and exchangeid Not in (13,14,18,256,395,398,405,477,496,846)) OR (BCti.Primaryflag = 0 and exchangeid in (13,14,18,256,395,398,405,477,496,846))) |
|
|
|
|
|