|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
returning only unique records
Hello, Im looking to return only records that are unique and if a record is not unique not return it.
i.e. if i had 30, 30, 45 I know distinct would return 30, 45 Im looking for something that would only return 45 any ideas? thanks in advance for the help JH |
|
#2
|
||||
|
||||
|
Count the number of values you have, this will give you 1 record for each value
select count(value), value from table you'll end up with something like this count of value ¦ value 2¦30 1¦45 in your where statement exclude count(value)>1 select count(value), value from table where count(value)=1 |
|
#3
|
||||
|
||||
|
I have posted this on another thread aswell, it just occured to me it would be helpful here too:
Try a select distinct, this will give you all unique rows. |
|
#4
|
|||
|
|||
|
select col1
from table group by col1 having count(col1)=1 |
|
#5
|
||||
|
||||
|
You need to GROUP BY the field HAVING COUNT(fieldname) = 1.
Exactly like Dumbo's example. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > returning only unique records |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|