Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Order by values in delimited List
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00924189
Message ID:
00924198
Vues:
10
This message has been marked as the solution to the initial question of the thread.
Hi Kirk,

Try following (not tested). Change inlist UDF to return table varibale with 2 columns: Room # and SortOrder.
inlist UDF
* Val Ord
  110  1
   89  2
   10  3
...
JOIN  dbo.inlist(@tcDeptList) il ON il.val = dbo.meetings.RoomID 
ORDER BY  dbo.coRooms.deptdisplayorder, il.ord, dbo.meetings.begintime
>Tricky order by clause question. In the snippit of code below, I use a inlist function to determine if a roomID is in the passed list of rooms for selection purposes.
>
>
>and dbo.meetings.RoomID in (select val from dbo.inlist(@tcDeptList))
>ORDER BY  dbo.coRooms.deptdisplayorder,dbo.coRooms.RoomName, dbo.meetings.begintime
>
>
>Sample List Values
>
>110,110,89,10
>
>
>This works and gets me the right records. Now I need to change the order by to match the order of the room ID's in the list. Does anyone have a suggestion how I might be able to do that. This code is in a stored procedure currently.
>
>Thanks for any help.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform