Distinct - Ordre by ?

  • Thread starter Thread starter SpookiePower
  • Start date Start date
S

SpookiePower

My table looks like this - almost..

Autonumber(id) Test number
1 a 1
2 a 2
3 b 3
4 b 4

I have an SQL that looks like this -

SELECT DISTINCT test FROM table01 ORDER BY test DESC;

Insted of ordering by test, I would like to order by id.

I have tryed this -

SELECT DISTINCT test,id FROM table01 ORDER BY id DESC;

But it will not work. What can I do ?
 
SELECT Table01.test
FROM Table01
GROUP BY Table01.test
ORDER BY Min(Table01.id) DESC;

MIN or MAX in the Order By clause. Your call.
 
SpookiePower said:
My table looks like this - almost..

Autonumber(id) Test number
1 a 1
2 a 2
3 b 3
4 b 4

I have an SQL that looks like this -

SELECT DISTINCT test FROM table01 ORDER BY test DESC;

Insted of ordering by test, I would like to order by id.

I have tryed this -

SELECT DISTINCT test,id FROM table01 ORDER BY id DESC;

But it will not work. What can I do ?


Since the id field is unique, Distinct will have no effect
(except slowing the query down).

What result were you hoping to get?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top