1.11M Members

SQL to display duplicate data once

 
0
 

Have a database table with various tasks and each has a time against it that it should take, some tasks have the same time. I now need to display these times in a drop down list but only want to display each time once, how can I do this?

 
0
 

Hello,

Try something like this substituting your table and field names:

select table.timefield,
count(table.timefield) AS NumberOf
FROM
table
GROUP BY
table.timefield
HAVING
NumberOf > 1

This should give you only times where there is more than on row and the number of rows.

 
0
 

After I posted I realised I could alter the stored proc and use DISTINCT, hopefully this works. Thank you though, if DISTINCT doesn't work I'll try your way :)

 
0
 

Distinct will work perfectly. I read your request as wanting only times where ther were duplicates. Also look at group by for some options.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article