|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
hi,
i have this result set that i need to put into an order. it needs to be displayed as productid 12 70 17 69 20 68 64 71 every second product is sub product of the prior one. when i use where productid in(12,70,17,69,20,68,64,71) group by productid it produces the result set in ascending order.any idea how to fix it? thanks for your help in advance... ![]() |
|
#2
|
||||
|
||||
|
This sounds like a SQL question:
"ORDER BY [GROUP BY] *fieldname* DESC" at the end of your statement. Hope that helps. |
|
#3
|
|||
|
|||
|
i tried this but it still generates ascending order
order by CASE WHEN substring(ZoneName,1,3) = 'Nor' THEN ZoneID WHEN substring(ZoneName,1,3) = 'Tab' THEN ZoneID WHEN substring(ZoneName,1,3) = 'Gre' THEN ZoneID WHEN substring(ZoneName,1,3) = 'Joh' THEN ZoneID WHEN substring(ZoneName,1,3) = 'For' THEN ZoneID WHEN substring(ZoneName,1,3) = 'Ft.' THEN ZoneID WHEN substring(ZoneName,1,3) = 'Co ' THEN ZoneID WHEN substring(ZoneName,1,3) = 'Woo' THEN ZoneID END ![]() |
|
#4
|
|||
|
|||
|
i figured it out...
![]() |
|
#5
|
|||
|
|||
|
Instead of hardcoding all the sort logic, which will probably be a maintenance headache down the line (what happens when another zoneName is added? When one is removed? When the order changes?)
I would create another field in the table called "sortID" and sort based on that. All the sorting just falls out that way.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#6
|
|||
|
|||
|
Quote:
bocmaxima gave you the answer already. Don't listen to FALCONEYES... First of all you can only order one COLUMN then the second one should just follow after the first sorting you try to do another query or sort afterwards your going to reorder according to that this is a common SQL topic see if you can find a SQL book instead of whatever your referencing Nothing? Get a SQL book... Maybe I shouldn't help since this is not 101 SQL -- this is order,group question probably first 10 pages of any SQL book... I don't know how you figured out how to use in(x,x,x,x) but not GROUP / ORDER but needless to say. Sidenote: SQL forum probably posted ORDER/GROUPs in FAQs. select * from table where productid in(12,70,17,69,20,68,64,71) order by productid DESC, sortID group by productid, sortID |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Ordering Result Set of <cfquery> |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|