![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
SQL select distinct
Say I'm trying to select some records from table "info" where "x > 5" and "y < 5" and z is distinct in the results. so i would get at most ONE record that meets the condition for each z. I tried
SELECT DISTINCT x,y,z FROM info WHERE x > 5 AND y < 5 |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I think it's just a matter of how you used (placed) the token, DISTINCT. You can achieve the same results with:
SELECT x, y, z FROM info WHERE x > 5 AND y < 5 GROUP BY z (assuming I read your intentions correctly, there's a DISTINCT possibility I didn't)
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
After 20+ tries i got it. Thanks.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|