Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL 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:
  #1  
Old May 13th, 2005, 03:11 AM
smrtelnik smrtelnik is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 11 smrtelnik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 43 m 38 sec
Reputation Power: 0
Problems with "order by char field"...

Hi all.
I have another one problem. I have select. It looks like:

SELECT tableA.fieldA,
tableB.FieldA,
tableC.FieldA
FROM tableA
LEFT JOIN tableB ON Some conditions
LEFT JOIN tableC ON Some conditions
ORDER BY tableA.fieldA


A very simple example. But tableA.fieldA is a character field (CHAR (10)), and it contains numeric and also alpha characters. Like: "32ad". I want to sort this select by this field, but this way. For examle, tableA.fieldA contains this values: "1","23","327","185,""15","256","99","a89","c52","a77"

After sorting I want this: "1","15","23","99","256","327","a77","a89","c52"

But I get only this: "1","15","185","23","256","327","99","a77","a89","c52"

I tried this,

SELECT LPAD(RTRIM(tableA.fieldA),10,' ') AS Alias,
tableB.FieldA,
tableC.FieldA
FROM tableA
LEFT JOIN tableB ON Some conditions
LEFT JOIN tableC ON Some conditions
ORDER BY Alias


but it was also not good.

Can you help me with this problem? Thank you.

Reply With Quote
  #2  
Old May 16th, 2005, 05:28 AM
fikret fikret is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Sarajevo, Bosnia
Posts: 111 fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 h 17 m 43 sec
Reputation Power: 8
Quote:
Originally Posted by smrtelnik
Hi all.
A very simple example. But tableA.fieldA is a character field (CHAR (10)), and it contains numeric and also alpha characters. Like: "32ad". I want to sort this select by this field, but this way. For examle, tableA.fieldA contains this values: "1","23","327","185,""15","256","99","a89","c52","a77"

After sorting I want this: "1","15","23","99","256","327","a77","a89","c52"

But I get only this: "1","15","185","23","256","327","99","a77","a89","c52"


It is correct behaviour. You cannot sort strings as integers...
Engine know how to sort numbers or how to sort strings. You cannot mix that.
Actually, you can do what you ask, but with some more complex operations in stored procedure.
There is no simple answer for this...

--
Best regards,
Fikret Hasovic http://fikret.fbtalk.net
USAID TAMP Senior Programmer
* FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
* JEDI VCS contributor
http://jedivcs.sourceforge.net/
* Firebird and Fyracle news
http://www.fyracle.org

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Problems with "order by char field"...


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