Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

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:
  #1  
Old December 4th, 2003, 12:44 AM
bungle_ bungle_ is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 5 bungle_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Order by not working properly

Here is my problem,

I have a table with sessions, and a table with events. Each event has multiple sessions. I want to list the events in order of when their earliest session is on.

The query does this, but it does not do the ordering of the date properly in the main query. e.g.
12/7/2003
12/5/2003
2/4/2004

SELECT tblEvent.intID, tblEvent.strTitle, tblEvent.strURL, (SELECT tblSession.dtmSessionDate FROM tblSession WHERE tblSession.intEvent=tblEvent.intID ORDER BY dtmSessionDate) AS Expr1
FROM tblWorkflow INNER JOIN tblEvent ON tblWorkflow.intEvent = tblEvent.intID
WHERE (((tblEvent.dtmDisplayFrom)<=Date()) AND ((tblEvent.dtmDisplayTo)>=Date()) AND ((tblEvent.dtmDisplayURLFrom)<=Date()) AND ((tblEvent.dtmDisplayURLTo)>=Date()) AND ((tblWorkflow.intStep)=5))
ORDER BY 4;

This is most annoying, any help would be appreciated either in the form of a query that works for this problem, or fixing this one.

Reply With Quote
  #2  
Old December 4th, 2003, 10:01 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,716 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 18 h 25 m 10 sec
Reputation Power: 986
format your dates as yyyy-mm-dd, or, if you really require mm-dd-yyyy for display purposes, add another column as yyyy-mm-dd for sorting purposes

rudy

Reply With Quote
  #3  
Old December 4th, 2003, 03:48 PM
bungle_ bungle_ is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 5 bungle_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, that's a good idea.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Order by not working properly


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 5 hosted by Hostway