|
 |
access thread: Sorting SQL queries
Message #1 by "Andrew Payne" <andrew@p...> on Wed, 22 Jan 2003 11:42:10
|
|
I have a query that I've created using VBA code but I need to sort by a
specific field (Drawing Number). I want to do an ascending sort, what
line of code do I need to add to get it to do this?
Thanks
Andrew
Message #2 by "George Oro" <george@c...> on Wed, 22 Jan 2003 15:40:12 +0400
|
|
SELECT * FROM YourTable ORDER BY Drawing Number
> -----Original Message-----
> From: Andrew Payne [mailto:andrew@p...]
> Sent: Wednesday, January 22, 2003 11:42 AM
> To: Access
> Subject: [access] Sorting SQL queries
>
>
> I have a query that I've created using VBA code but I need to sort by a
> specific field (Drawing Number). I want to do an ascending sort, what
> line of code do I need to add to get it to do this?
>
> Thanks
>
> Andrew
>
Message #3 by "John Fejsa" <John.Fejsa@h...> on Thu, 23 Jan 2003 08:44:21 +1100
|
|
SELECT fieldlist
FROM table
WHERE selectcriteria
[ORDER BY field1 [ASC | DESC ][, field2 [ASC | DESC ]][, ...]]]
Examples:
Order by Drawing Number in Ascending Order
=================================
SELECT [Drawing Number], MyOtherField, MyOtherField2 FROM MyTable
ORDER BY [Drawing Number];
You dont have to specifiy ascending order (it's defaults to ascending if
non specified.)
Order by Drawing Number in Descending Order
=================================
SELECT [Drawing Number], MyOtherField, MyOtherField2 FROM MyTable
ORDER BY [Drawing Number] DESC;
You HAVE to specifiy descending order, because it defaults to ascending
if non specified.
Hope it's of some help...
____________________________________________________
John Fejsa
Systems Analyst/Computer Programmer
Hunter Centre for Health Advancement
Locked Bag 10, WALLSEND NSW 2287
Phone: (02) 4924 6336 Fax: (02) 4924 6209
www.hcha.org.au
____________________________________________________
The doors we open and close each day decide the lives we live
____________________________________________________
CONFIDENTIALITY & PRIVILEGE NOTICE
>>> andrew@p... 22/01/2003 22:42:10 >>>
I have a query that I've created using VBA code but I need to sort by a
specific field (Drawing Number). I want to do an ascending sort, what
line of code do I need to add to get it to do this?
Thanks
Andrew
This message is intended for the addressee named
and may contain confidential information.
If you are not the intended recipient, please
delete it and notify the sender.
Views expressed in this message are those of the
individual sender, and are not necessarily the
views of Hunter Health.
Message #4 by "John Ruff" <papparuff@a...> on Wed, 22 Jan 2003 13:47:45 -0800
|
|
Quick Qualification;
The [Drawing Number] field will be set in ascending order automatically
only
if it is the PrimaryKey (PK). If it is not the PK, then you will need
set
[Drawing Number] by ASC order
John V. Ruff - The Eternal Optimist :-)
Always Looking For Contract Opportunities
www.noclassroom.com
Live software training
Right over the Internet
Home: xxx.xxx.xxxx
Cell: 253.307/2947
9306 Farwest Dr SW
Lakewood, WA 98498
"Commit to the Lord whatever you do,
and your plans will succeed." Proverbs 16:3
-----Original Message-----
From: John Fejsa [mailto:John.Fejsa@h...]
Sent: Wednesday, January 22, 2003 1:44 PM
To: Access
Subject: [access] Re: Sorting SQL queries
SELECT fieldlist
FROM table
WHERE selectcriteria
[ORDER BY field1 [ASC | DESC ][, field2 [ASC | DESC ]][, ...]]]
Examples:
Order by Drawing Number in Ascending Order
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D
SELECT [Drawing Number], MyOtherField, MyOtherField2 FROM MyTable ORDER
BY
[Drawing Number];
You dont have to specifiy ascending order (it's defaults to ascending if
non
specified.)
Order by Drawing Number in Descending Order
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D SELECT [Drawing Number], MyOtherField,
MyOtherField2 FROM MyTable ORDER BY [Drawing Number] DESC;
You HAVE to specifiy descending order, because it defaults to ascending
if
non specified.
Hope it's of some help...
____________________________________________________
John Fejsa
Systems Analyst/Computer Programmer
Hunter Centre for Health Advancement
Locked Bag 10, WALLSEND NSW 2287
Phone: (02) 4924 6336 Fax: (02) 4924 6209
www.hcha.org.au ____________________________________________________
The doors we open and close each day decide the lives we live
____________________________________________________
CONFIDENTIALITY & PRIVILEGE NOTICE
>>> andrew@p... 22/01/2003 22:42:10 >>>
I have a query that I've created using VBA code but I need to sort by a
specific field (Drawing Number). I want to do an ascending sort, what
line of code do I need to add to get it to do this?
Thanks
Andrew
This message is intended for the addressee named
and may contain confidential information.
If you are not the intended recipient, please
delete it and notify the sender.
Views expressed in this message are those of the
individual sender, and are not necessarily the
views of Hunter Health.
|
|
 |