select top(10) from customer order by customer_id desc
views:
320answers:
4
+7
A:
select * from (select top 10 * from customer order by customer_id desc) a order by customer_id
ps
2009-11-19 19:26:10
Shouldn't it be "order by a.customer_id"?
Brandon
2009-11-19 19:28:23
I dont think it is necessarry.. it is just like doing select top 10 * from customer c order by customer_id desc
ps
2009-11-19 19:40:51
the query above is what you want...or atleast that is what i think..
ps
2009-11-19 20:20:15
sorry for that it works....
2009-11-19 20:55:36
A:
alter view view_123 as
(
select top(10) * from Country_Profile123 order by country_id desc
)
select top(10) * from view_123 order by country_id asc
first create view and then fire a query on that view... you got what you want
Sikender
2009-11-19 20:52:19
+1
A:
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
p.campbell
2009-11-19 20:54:56
+1
A:
This work fine in MS SQL but for MySQL we would have to go SELECT * FROM customer ORDER BY customer_id DESC LIMIT 10
Stéphane
2009-11-19 20:58:27
I am not sure but i think in mysql it will beselect * from (select * from customer order by customer_id desc limit 10) a order by customer_idor something similar.
ps
2009-11-19 21:41:21
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éphane
2009-11-30 21:08:38