For my SQL gurus out there
I am going to try and make this as generic as possible, maybe someone knows how to do it and I can incorporate it into my more complex query. Take a result set like this:
15001 0 15001 3 10004 3 11002 4 11002 4 Basically want I want to do is this - I don't want to show the record at all if the value in column B is in (1, 3). This is done with a simple "not in" statement. But I also don't want that corresponding value from column A showing up then. For instance, 15001 - since that has one record that has a value of 3 in column B, I don't want 15001 records to show up at all. I have some tried some EXISTS minus NOT EXISTS stuff that isn't working. Any suggestions for what I can try? It doesn't seem TOO hard, but I am missing something somewhere... |
Sounds like you need a subselect:
select A,B from TABLE where A not in (select A from TABLE where B in (1, 3) or a join: select T1.A,T1.B from TABLE as T1 join TABLE as T2 on T1.A=T2.A where T2.B not in (1, 3) |
Wow, I told you I didn't think it was too hard...I think I was just overthinking it. I think the subselect works perfectly. Thanks MIJB!
|
I threw that into my main query, MIJB, and that seemed to work perfectly. Thanks again!
|
including the missing parenthesis at the end? ;)
|
All times are GMT -5. The time now is 10:10 PM. |
Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.