Just nu i M3-nätverket
Jump to content

UNION-sortering


SimonHugoson

Recommended Posts

Tja! Jag vill selecta top 10 från en tabell och top 5 från en annan, sen vill jag sortera dem efter datum (eller id desc). Men det blir konsigt... Så här har jag skrivit nu:

SELECT TOP 10 * FROM tabell1 WHERE Samman NOT LIKE 'hejhej' ORDER BY ID DESC

UNION

SELECT TOP 5 * FROM tabell2 ORDER BY ID DESC

Link to comment
Share on other sites

Det räcker med en ORDER BY sist SQL satsen.

 

 

==Coleburn==

 

--------------------

"It takes a lot of knowledge to

really mess something up!"

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...