If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > SQL-problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-23-04, 10:48
Sham81 Sham81 is offline
Registered User
 
Join Date: Oct 2003
Location: Finland
Posts: 80
SQL-problem

Hi!

I have problem sorting my table. It contains both text and numeric data. I made a links which could be used to sort the table by clicking the column title. I have problems sorting the numeric columns (for example 110 was smaller than 98). After a quick search with google, I found out that I should use COLLATE NUMERIC with the ORDER BY-clause. So I made the following select case:

-----------------------------------
sort = Request.QueryString("SortBy")

select case sort

case ""
sql = "SELECT * FROM Autot"

(this is for text-columns)
case "Aureknro", "Aumerkki", "Aumalli", "Aukori", "Auvari"
sql = "SELECT * FROM Autot ORDER BY "& sort &""

(this is for numeric-columns, and it doesn't work)
case "Auvm", "Auajetutkm", "Auhinta"
sql = "SELECT * FROM Autot ORDER BY "& sort &" COLLATE NUMERIC"

end select
-----------------------------------

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Auvm COLLATE NUMERIC'.
Reply With Quote
  #2 (permalink)  
Old 08-23-04, 12:49
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Sounds like you have your numeric values in character fields in your table. You shouldn't have to change collations to do this type of sorting. Double check your table "Autot" and make sure columns "Auvm," "Auajetutkm," and "Auhint" have numeric datatypes.
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #3 (permalink)  
Old 08-23-04, 13:08
Sham81 Sham81 is offline
Registered User
 
Join Date: Oct 2003
Location: Finland
Posts: 80
Thanks Seppuku!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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