May 5, 2006 #1 markj11 Programmer Mar 24, 2006 11 US TableA A B 1 X 1 Y 2 X I want my results to be 1 X because B = Y. This is kind of what I was tring: Code: SELECT DISTINCT A, CASE WHEN B = 'X' THEN B ELSE '' END AS B FROM tableA WHERE B = 'Y'
TableA A B 1 X 1 Y 2 X I want my results to be 1 X because B = Y. This is kind of what I was tring: Code: SELECT DISTINCT A, CASE WHEN B = 'X' THEN B ELSE '' END AS B FROM tableA WHERE B = 'Y'
May 5, 2006 1 #2 SQLBill MIS May 29, 2001 7,777 US Maybe....... Code: SELECT DrvA.A, DrvA.B FROM (SELECT A,B FROM TableA WHERE B = 'Y') DrvA WHERE DrvA.B <> 'Y' -SQLBill Posting advice: FAQ481-4875 Upvote 0 Downvote
Maybe....... Code: SELECT DrvA.A, DrvA.B FROM (SELECT A,B FROM TableA WHERE B = 'Y') DrvA WHERE DrvA.B <> 'Y' -SQLBill Posting advice: FAQ481-4875
May 5, 2006 #3 SQLBill MIS May 29, 2001 7,777 US Maybe... Code: SELECT TblA.A, TblA.B FROM TableA TblA LEFT OUTER JOIN (SELECT A FROM TableA WHERE B = 'Y') TblB ON TblA.A = TblB.A WHERE TblA.B <> 'Y' -SQLBill Posting advice: FAQ481-4875 Upvote 0 Downvote
Maybe... Code: SELECT TblA.A, TblA.B FROM TableA TblA LEFT OUTER JOIN (SELECT A FROM TableA WHERE B = 'Y') TblB ON TblA.A = TblB.A WHERE TblA.B <> 'Y' -SQLBill Posting advice: FAQ481-4875
May 5, 2006 Thread starter #4 markj11 Programmer Mar 24, 2006 11 US Thank you. That would work great but I just realized the table is like this A B C 1 X AA 1 Y BB 2 X AA and I want 1 BB because B = X Upvote 0 Downvote
Thank you. That would work great but I just realized the table is like this A B C 1 X AA 1 Y BB 2 X AA and I want 1 BB because B = X
May 5, 2006 Thread starter #5 markj11 Programmer Mar 24, 2006 11 US Thanks, A varaition of the last SQL will do just fine. Upvote 0 Downvote