select top(10) from customer order by customer_id desc
4 Answers
select *
from (select top 10 * from customer order by customer_id desc) a
order by customer_id
-
-
I dont think it is necessarry.. it is just like doing select top 10 * from customer c order by customer_id desc– ps.Commented Nov 19, 2009 at 19:40
This work fine in MS SQL but for MySQL we would have to go SELECT * FROM customer ORDER BY customer_id DESC LIMIT 10
-
I am not sure but i think in mysql it will be select * from (select * from customer order by customer_id desc limit 10) a order by customer_id or something similar.– ps.Commented Nov 19, 2009 at 21:41
-
Or you could go Select * From customer Where customer_id in (select customer_id order by customer_id desc) order by customer_id. This way you don't transfer the whole database only for the customer_id. This will depend how many records you will get back. A few you don't mind, but if you have a large recordset and many record the economy of bandwidth will be noticed :)– StéphaneCommented Nov 30, 2009 at 21:08
It seems you're missing the column list that you'd like retrieved from the table.
Consider:
select top(10)
*
from customer order by customer_id desc
or
select top(10)
customer_id, customer_name
from customer order by customer_id desc