|
 |
asp_web_howto thread: Sorting Problem
Message #1 by "Sidney Fuerte" <fuertsj1104@y...> on Thu, 18 Apr 2002 16:47:25
|
|
Hi All,
How can I sort this kind of data:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
2002 QTR should come first, I tried using this SQL Statement:
I used ORDER BY FldDate ASC; but I get this output:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
I am using Access 2000 as my Database.
I would really appreciate any help that you can give :)
Thanks/Regagrds
Sidney
Message #2 by "Johnson, Israel" <IJohnson@R...> on Thu, 18 Apr 2002 11:44:28 -0400
|
|
try including DESC in your SQL instead of ASC
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 12:47 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Sorting Problem
Hi All,
How can I sort this kind of data:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
2002 QTR should come first, I tried using this SQL Statement:
I used ORDER BY FldDate ASC; but I get this output:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
I am using Access 2000 as my Database.
I would really appreciate any help that you can give :)
Thanks/Regagrds
Sidney
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #3 by "Sidney Fuerte" <fuertsj1104@y...> on Thu, 18 Apr 2002 16:56:12
|
|
You have a point there... but if I use DESC this is the output:
4TH QTR 2001
3RD QTR 2001
2ND QTR 2001
1ST QTR 2002
1ST QTR 2001
I already thought of that :) I was just thingking if I cant sort it in SQL
directly... is there another way around? like in ASP? is there a way I can
sort this?
Best Regards
Sidney
> try including DESC in your SQL instead of ASC
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 12:47 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Sorting Problem
Hi All,
How can I sort this kind of data:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
2002 QTR should come first, I tried using this SQL Statement:
I used ORDER BY FldDate ASC; but I get this output:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
I am using Access 2000 as my Database.
I would really appreciate any help that you can give :)
Thanks/Regagrds
Sidney
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #4 by "Johnson, Israel" <IJohnson@R...> on Thu, 18 Apr 2002 11:58:51 -0400
|
|
In T-SQL, I believe you can use the "LEFT(Name,number of places)" function,
however, since the year is to be sorted, it would be best practice if the
years was in a separate column.
Experiment with the "LEFT" function and see what happens...
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 12:56 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Sorting Problem
You have a point there... but if I use DESC this is the output:
4TH QTR 2001
3RD QTR 2001
2ND QTR 2001
1ST QTR 2002
1ST QTR 2001
I already thought of that :) I was just thingking if I cant sort it in SQL
directly... is there another way around? like in ASP? is there a way I can
sort this?
Best Regards
Sidney
> try including DESC in your SQL instead of ASC
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 12:47 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Sorting Problem
Hi All,
How can I sort this kind of data:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
2002 QTR should come first, I tried using this SQL Statement:
I used ORDER BY FldDate ASC; but I get this output:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
I am using Access 2000 as my Database.
I would really appreciate any help that you can give :)
Thanks/Regagrds
Sidney
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #5 by william.sze@s... on Thu, 18 Apr 2002 12:01:00 -0400
|
|
I think you can add one more column in your SELECT statment by using
SUBSTRING(FldDate,8,4) AS DateSort and then
ORDER BY DateSort Desc, FldDate Desc
william
"Sidney
Fuerte" To: "ASP Web HowTo" <asp_web_howto@p...>
<fuertsj1104@y... cc:
ahoo.com> Subject: [asp_web_howto] RE: Sorting Problem
04/18/02 12:56
PM
Please respond
to "ASP Web
HowTo"
You have a point there... but if I use DESC this is the output:
4TH QTR 2001
3RD QTR 2001
2ND QTR 2001
1ST QTR 2002
1ST QTR 2001
I already thought of that :) I was just thingking if I cant sort it in SQL
directly... is there another way around? like in ASP? is there a way I can
sort this?
Best Regards
Sidney
> try including DESC in your SQL instead of ASC
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 12:47 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Sorting Problem
Hi All,
How can I sort this kind of data:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
2002 QTR should come first, I tried using this SQL Statement:
I used ORDER BY FldDate ASC; but I get this output:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
I am using Access 2000 as my Database.
I would really appreciate any help that you can give :)
Thanks/Regagrds
Sidney
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #6 by "Spam Free" <spam.free@n...> on Thu, 18 Apr 2002 18:34:03 +0100
|
|
Hi,
If the field is always the same length why try sorting using
ORDER BY Right (FldDate,4), Left (FldDate,1)
Regards
spam.free@n...
----- Original Message -----
From: "Sidney Fuerte" <fuertsj1104@y...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Thursday, April 18, 2002 4:47 PM
Subject: [asp_web_howto] Sorting Problem
> Hi All,
>
> How can I sort this kind of data:
>
> 1ST QTR 2001
> 1ST QTR 2002
> 2ND QTR 2001
> 3RD QTR 2001
> 4TH QTR 2001
>
> 2002 QTR should come first, I tried using this SQL Statement:
>
> I used ORDER BY FldDate ASC; but I get this output:
>
> 1ST QTR 2001
> 1ST QTR 2002
> 2ND QTR 2001
> 3RD QTR 2001
> 4TH QTR 2001
>
> I am using Access 2000 as my Database.
>
> I would really appreciate any help that you can give :)
>
> Thanks/Regagrds
> Sidney
>
> ---
>
> Improve your web design skills with these new books from Glasshaus.
>
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
> http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
> http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20
>
Message #7 by Eric Hobbs <ehobbs@l...> on Thu, 18 Apr 2002 10:40:30 -0700
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C1E700.223C06A0
Content-Type: text/plain
Sidney,
Try this in SQL View for an access query:
SELECT Table1.test
FROM Table1
ORDER BY (Right(table1!test,4)) DESC , Table1.test DESC
(where "Table1" is your table and "test" is the field with those values).
I'm not quite sure how you wanted it sorted - the example shown above sorts
it like:
1ST QTR 2002
4TH QTR 2001
3RD QTR 2001
2ND QTR 2001
1ST QTR 2001
Changing the last DESC in "Table1.test DESC" to ASC will give you:
1ST QTR 2002
1ST QTR 2001
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
- Eric
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 9:56 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Sorting Problem
You have a point there... but if I use DESC this is the output:
4TH QTR 2001
3RD QTR 2001
2ND QTR 2001
1ST QTR 2002
1ST QTR 2001
I already thought of that :) I was just thingking if I cant sort it in SQL
directly... is there another way around? like in ASP? is there a way I can
sort this?
Best Regards
Sidney
> try including DESC in your SQL instead of ASC
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 12:47 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Sorting Problem
Hi All,
How can I sort this kind of data:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
2002 QTR should come first, I tried using this SQL Statement:
I used ORDER BY FldDate ASC; but I get this output:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
I am using Access 2000 as my Database.
I would really appreciate any help that you can give :)
Thanks/Regagrds
Sidney
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #8 by "Sidney Fuerte" <fuertsj1104@y...> on Thu, 18 Apr 2002 19:12:10
|
|
Thank you very much evrybody!
the Right() fucntion is working perfectly fine!, Thanks Eric!!
By the way will this function work in SQL Server 7.0?
Thanks/Regards
Sidney
> This message is in MIME format. Since your mail reader does not
understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C1E700.223C06A0
Content-Type: text/plain
Sidney,
Try this in SQL View for an access query:
SELECT Table1.test
FROM Table1
ORDER BY (Right(table1!test,4)) DESC , Table1.test DESC
(where "Table1" is your table and "test" is the field with those values).
I'm not quite sure how you wanted it sorted - the example shown above sorts
it like:
1ST QTR 2002
4TH QTR 2001
3RD QTR 2001
2ND QTR 2001
1ST QTR 2001
Changing the last DESC in "Table1.test DESC" to ASC will give you:
1ST QTR 2002
1ST QTR 2001
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
- Eric
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 9:56 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Sorting Problem
You have a point there... but if I use DESC this is the output:
4TH QTR 2001
3RD QTR 2001
2ND QTR 2001
1ST QTR 2002
1ST QTR 2001
I already thought of that :) I was just thingking if I cant sort it in SQL
directly... is there another way around? like in ASP? is there a way I can
sort this?
Best Regards
Sidney
> try including DESC in your SQL instead of ASC
-----Original Message-----
From: Sidney Fuerte [mailto:fuertsj1104@y...]
Sent: Thursday, April 18, 2002 12:47 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Sorting Problem
Hi All,
How can I sort this kind of data:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
2002 QTR should come first, I tried using this SQL Statement:
I used ORDER BY FldDate ASC; but I get this output:
1ST QTR 2001
1ST QTR 2002
2ND QTR 2001
3RD QTR 2001
4TH QTR 2001
I am using Access 2000 as my Database.
I would really appreciate any help that you can give :)
Thanks/Regagrds
Sidney
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
|
|
 |