ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old August 24th, 2004, 03:57 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
Question Ordering Result Set of <cfquery>

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...


Reply With Quote
  #2  
Old August 24th, 2004, 04:09 PM
bocmaxima's Avatar
bocmaxima bocmaxima is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2004
Location: Tucson, Sonora
Posts: 1,322 bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 17 h 46 m 5 sec
Reputation Power: 22
Send a message via AIM to bocmaxima
This sounds like a SQL question:
"ORDER BY [GROUP BY] *fieldname* DESC"
at the end of your statement.

Hope that helps.

Reply With Quote
  #3  
Old August 24th, 2004, 04:26 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
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

Reply With Quote
  #4  
Old August 24th, 2004, 04:36 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
Talking

i figured it out...

Reply With Quote
  #5  
Old August 24th, 2004, 08:10 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
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

Reply With Quote
  #6  
Old October 1st, 2004, 07:44 PM
z44sms z44sms is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 9 z44sms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
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.


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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Ordering Result Set of <cfquery>


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway