Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default SQL ORDER BY


HI

I use this question and it works fine but I want to sort it in the same
order as the "IN list"

SELECT ID, firstname, lastname FRON person WHERE ID IN (6,2,8)

Now I want it to be sorted in the same order as "IN (6,2,8)" I mhave
tried ORDER BY FIELD(ID, 6,2,8) but then I get an error

IS thier someone who knows somthing about this?

Thanks in advance


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default SQL ORDER BY

You'll have to use something like decode() to do this.

.... order by decode(ID,6,1,2,2,8,3)

or whatever is the equivalent in your particular database.

Tim

"Kalle" wrote in message
...

HI

I use this question and it works fine but I want to sort it in the same
order as the "IN list"

SELECT ID, firstname, lastname FRON person WHERE ID IN (6,2,8)

Now I want it to be sorted in the same order as "IN (6,2,8)" I mhave
tried ORDER BY FIELD(ID, 6,2,8) but then I get an error

IS thier someone who knows somthing about this?

Thanks in advance


*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default SQL ORDER BY



Hi


Thanks for your answer but it does't work.

I use an excel worksheet as datebase. Maybe it does't support decode?

Kalle

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default SQL ORDER BY

sSQL = " select col1, col2 from src_rng_name " & _
" order by switch(col1=6, 1, col1=6, 2, col1=6, 3) "

Tim

"Kalle" wrote in message
...


Hi


Thanks for your answer but it does't work.

I use an excel worksheet as datebase. Maybe it does't support decode?

Kalle

*** Sent via Developersdex http://www.developersdex.com ***



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change series plotting order without changing legend order? PatrickM Charts and Charting in Excel 6 December 2nd 09 07:43 PM
For chart syles, why doesn't color order match series order? AMiller Charts and Charting in Excel 1 October 29th 09 12:02 AM
How stop Excel file UK date order changing to US order in m.merge Roger Aldridge Excel Discussion (Misc queries) 1 October 9th 07 11:52 PM
Daily Macro to Download Data, Order and paste in order Iarla Excel Worksheet Functions 1 November 17th 04 01:59 PM
Daily Macro to Download Data, Order and paste in order Iarla Excel Programming 1 November 17th 04 11:55 AM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"