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?

Recommended Answers

All 3 Replies

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.

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 :)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.