Here is the query I am using:
select top 1 'Return To IPACS' as name, 'http://domain:88' as link
union
select name,link
from jrm_intranetlinks l
inner join jrm_intranetpermissions p on l.id = p.linkid
where p.userid = 155
order by case name when 'Home' then 2 when 'Team' then 1 end desc, name
Here is the error message I am receiving:
Msg 104, Level 16, State 1, Line 1
ORDER BY items must appear in the select list if the statement contains a UNION, INTERSECT or EXCEPT operator.
The bottom set above returns a list we use for link names, and the right column provides the path they link to. We need to add a default link for everyone which is why we are trying the union part since this link everyone will get and the other table displays links based on permission.
It works just fine without the order by clause, but i need the return to ipacs one at the top, then home, then team and rest ordered desc.
What am I doing wrong here?
CASE? Also,TOPtypically pairs withORDER BY