Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning unique values in one column

Status
Not open for further replies.

neil6179

Programmer
Oct 31, 2005
3
GB
Hi,

I currently have a table called “pages” containing the following columns:
pageid, domainid, location, lastread

I've put together a query that returns 10 rows with the lowest “lastread” values, for which this works fine:
SELECT * FROM pages ORDER BY lastread ACS LIMIT 10;

I now the have the added complication that I want to make sure each value in “domainid” is unique. That is to say, not repeated within the 10 results returned. I though I might be able to do something using “GROUP BY domainid” but that cannot just work on the one column as far as I can see.

Also the “DISTINCT” keyword only ensures the entire row is unique.

If anyone can offer me some advice on how I could go about this or if its ever possible from one SQL statement I would be most grateful.

Thanks
Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top