code_junkie

Multiple NOT distinct

Nov 12th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. A B C
  2. 1 x q
  3. 2 y w
  4. 3 y e
  5. 4 z r
  6. 5 z t
  7. 6 z y
  8.  
  9. B C
  10. y w
  11. y e
  12. z r
  13. z t
  14. z y
  15.  
  16. Select B, C
  17. From Table
  18. Where B In
  19. (Select B From Table
  20. Group By B
  21. Having COunt(*) > 1)
  22.  
  23. select *
  24. from
  25. my_table
  26. where
  27. B in
  28. (select B from my_table group by B having count(*) > 1)
  29.  
  30. select
  31. *
  32. from
  33. my_table t1,
  34. my_table t2
  35. where
  36. t1.B = t2.B
  37. and
  38. t1.C != t2.C
  39.  
  40. -- apparently you need to use <> instead of != in Access
  41. -- Thanks, Dave!
Add Comment
Please, Sign In to add comment