An ASP page outputs data from the query
"Select ThisAndThat from comments WHERE pageURL='" & pageURL & "' ORDER BY
threadID, datesent"
(Access mdb)
threadID is a string (OK, I know!), which means that 103 displays before 99.
Is there a way to write the SQL query to order them numerically? This would
be much easier for me than changing the data type and hunting down every
page that INSERTS or UPDATES the db.
Thanks, Giles 7 6338
You should correct the data instead of applying a band-aid. But, if you
choose not to:
ORDER BY CInt(threadID). ..
BUT NEXT TIME, STORE NUMERIC VALUES AS NUMERIC DATA!
Ray at work
"Giles" <gi***@nospam.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. An ASP page outputs data from the query "Select ThisAndThat from comments WHERE pageURL='" & pageURL & "' ORDER BY threadID, datesent" (Access mdb) threadID is a string (OK, I know!), which means that 103 displays before 99. Is there a way to write the SQL query to order them numerically? This would be much easier for me than changing the data type and hunting down every page that INSERTS or UPDATES the db. Thanks, Giles
Thanks very much Ray. I'll go and put on the spiky belt now..!.
"Ray Costanzo [MVP]" You should correct the data instead of applying a band-aid. But, if you choose not to:
ORDER BY CInt(threadID). ..
BUT NEXT TIME, STORE NUMERIC VALUES AS NUMERIC DATA!
Ray at work
"Giles" <gi***@nospam.c om> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. An ASP page outputs data from the query "Select ThisAndThat from comments WHERE pageURL='" & pageURL & "' ORDER BY threadID, datesent" (Access mdb) threadID is a string (OK, I know!), which means that 103 displays before 99. Is there a way to write the SQL query to order them numerically? This would be much easier for me than changing the data type and hunting down every page that INSERTS or UPDATES the db. Thanks, Giles
I have a simular problem with a extra twist
I was using invoice numbers in ORDER BY converting the invoice number to
Integer
but them someone in accounts for some silly reason started overwriting the
invoice numbers with text
I used the row id instead as this is for the most part the same order, but
no always. some times invoice numbers are entered out of order, so the fix
is not perfect.
I assume I can use some sort of SQL statement like
CASE isnumeric(invoi ceNumber )
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:eI******** *****@TK2MSFTNG P14.phx.gbl... You should correct the data instead of applying a band-aid. But, if you choose not to:
ORDER BY CInt(threadID). ..
BUT NEXT TIME, STORE NUMERIC VALUES AS NUMERIC DATA!
Ray at work
"Giles" <gi***@nospam.c om> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. An ASP page outputs data from the query "Select ThisAndThat from comments WHERE pageURL='" & pageURL & "' ORDER BY threadID, datesent" (Access mdb) threadID is a string (OK, I know!), which means that 103 displays before 99. Is there a way to write the SQL query to order them numerically? This would be much easier for me than changing the data type and hunting down every page that INSERTS or UPDATES the db. Thanks, Giles
Slim wrote: I have a simular problem with a extra twist I was using invoice numbers in ORDER BY converting the invoice number to Integer
but them someone in accounts for some silly reason started overwriting the invoice numbers with text
I used the row id instead as this is for the most part the same order, but no always. some times invoice numbers are entered out of order, so the fix is not perfect.
Do you want character entries to appear before or after numeric entries? I assume I can use some sort of SQL statement like CASE isnumeric(invoi ceNumber )
The original problem involved Access. I assume you are talking about SQL
Server? If so, then yes, CASE will be your solution, but I would avoid
ISNUMERIC ( http://www.aspfaq.com/show.asp?id=2390). Assuming you want the
character entries to appear after the numeric entries:
ORDER BY
CASE WHEN
PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN 999999999
ELSE CAST(invoiceNum ber AS int) END,
invoiceNumber
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:ev******** ******@TK2MSFTN GP09.phx.gbl... Slim wrote: I have a simular problem with a extra twist I was using invoice numbers in ORDER BY converting the invoice number to Integer
but them someone in accounts for some silly reason started overwriting the invoice numbers with text
I used the row id instead as this is for the most part the same order, but no always. some times invoice numbers are entered out of order, so the fix is not perfect. Do you want character entries to appear before or after numeric entries?
I assume I can use some sort of SQL statement like CASE isnumeric(invoi ceNumber )
The original problem involved Access. I assume you are talking about SQL Server? If so, then yes, CASE will be your solution, but I would avoid ISNUMERIC (http://www.aspfaq.com/show.asp?id=2390). Assuming you want the character entries to appear after the numeric entries:
actually before would be better as we are using looking at the last few
thanks for this ORDER BY CASE WHEN PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN 999999999 ELSE CAST(invoiceNum ber AS int) END, invoiceNumber
Bob Barrows
would this give them to me before?
ORDER BY
CASE WHEN
CAST(invoiceNum ber AS int)
ELSE PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN 999999999 END,
invoiceNumber
thanks
-- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup.
Slim wrote: ORDER BY CASE WHEN PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN 999999999 ELSE CAST(invoiceNum ber AS int) END, invoiceNumber
Bob Barrows
would this give them to me before?
ORDER BY CASE WHEN CAST(invoiceNum ber AS int) ELSE PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN 999999999 END, invoiceNumber
No, this will raise an error, which you would have discovered if you had
taken the 30 seconds to actually try it ... ;-)
This is how it would be done:
ORDER BY
CASE WHEN
PATINDEX('%[^0-9]%',invoiceNumbe r)=0 THEN 'zzzzzzzzzz'
ELSE invoiceNumber END,
CASE WHEN
PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN -1
ELSE CAST(invoiceNum ber AS int) END
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:OC******** ******@TK2MSFTN GP10.phx.gbl... Slim wrote: ORDER BY CASE WHEN PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN 999999999 ELSE CAST(invoiceNum ber AS int) END, invoiceNumber
Bob Barrows would this give them to me before?
ORDER BY CASE WHEN CAST(invoiceNum ber AS int) ELSE PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN 999999999 END, invoiceNumber
No, this will raise an error, which you would have discovered if you had taken the 30 seconds to actually try it ... ;-)
This is how it would be done: ORDER BY CASE WHEN PATINDEX('%[^0-9]%',invoiceNumbe r)=0 THEN 'zzzzzzzzzz' ELSE invoiceNumber END, CASE WHEN PATINDEX('%[^0-9]%',invoiceNumbe r)>0 THEN -1 ELSE CAST(invoiceNum ber AS int) END
Bob Barrows
thank very much, -- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Klaus Petersen |
last post by:
Hi ng.
I have a varchar field in my table, called Name.
I wanna do a selection, which is ordered by whether this field is empty or
not.
E.g. something like:
SELECT
|
by: Jeff Magouirk |
last post by:
Dear All,
I have written an update trigger that should write a message to an audit
table When I try to update any field in the table I recieve the following
error message -
Stirng or Binary data would be
trunicated
The statement has been termined.
|
by: Indrid Colt |
last post by:
Thank's for your help !
Indrid
|
by: pinkfloydhomer |
last post by:
How do I check if a string contains (can be converted to) an int? I
want to do one thing if I am parsing and integer, and another if not.
/David
|
by: Abhi |
last post by:
Hi..
I wanted the C source code in machine readable format for the book
"Numerical Recipes in C".
I got hold of the pdf version of the book somehow. Does anyone have the
complete C code of the book?. If yes,..can you please mail me the code
or somehow share it with me?.
With Regards,
Abhishek S
| |
by: Kevin Burton |
last post by:
I have a set of XSD's that I would like to build some classes from. When I
run the xsd tool I get a warning that the following is not "legal":
<xsd:restriction base="xsd:string">
I have seen this construct in other XSD's so I am sure it is legal. How can
I get the xsd tool to not complain about using string as a base?
Thank you.
|
by: Trapulo |
last post by:
I've a webservice with a string parameter.
I call this webservice passing a string that is 1129 chars length. On the
webservice, the received string is 1146 length (I tested sizes with
string.length property). String's contents seem be teh same, so I think
there is some encoding difference (is this possibile?). The problem is that
I sign this string, so signature validation fails :(
What can be the problem?
|
by: bwaichu |
last post by:
Now, I read the faq, and it suggests using sprintf. However,
I want to all ways know where the integer finishes in the string.
Basically, I want to:
nbr | other data
But the other data all ways has to start at the same place. I had
some problems using sprintf to accomplish this requirement. Maybe
I am overlooking something. But sprintf translates the nbr exactly
into
|
by: neovantage |
last post by:
Hey all,
I am creating a xml file in this format
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customers>
<customer>
<category>Broschüren</category>
<number>4</number>
<email>abc@xyz.net</email>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |