Front Office Football Central

Front Office Football Central (http://forums.operationsports.com/fofc//index.php)
-   FOFC Archive (http://forums.operationsports.com/fofc//forumdisplay.php?f=27)
-   -   For my SQL gurus out there (http://forums.operationsports.com/fofc//showthread.php?t=77547)

PackerFanatic 04-23-2010 10:46 AM

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...

MIJB#19 04-23-2010 10:50 AM

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)

PackerFanatic 04-23-2010 10:53 AM

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!

PackerFanatic 04-23-2010 11:22 AM

I threw that into my main query, MIJB, and that seemed to work perfectly. Thanks again!

MIJB#19 04-23-2010 12:02 PM

including the missing parenthesis at the end? ;)


All times are GMT -5. The time now is 02:05 AM.

Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.