473,499 Members | 1,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I use ORDER BY with a custom column name?

2 New Member
I'm using Access 2000 and I'm trying to do something like this:

SELECT Employee, Status as ss
FROM data
ORDER BY ss

This query doesn't run since it appears that Access doesn't recognize "ss" as a valid field in the ORDER BY clause. How can I get this effect?

BTW, it won't do for me to use "ORDER BY Status". This is a very simplified version of the actual query I'm trying to use in my program. In the full problem I have columns in two joined tables with the same name. The part of my code that creates the order by part of the query doesn't have knowledge of which field to use for sorting so I wanted to use a generic name there and specify the correct column using the "as" construct. I've used this trick many times while working with MySql databases. I was hoping that I could do the same thing with Access.

Any help will be appreciated.

_M_
May 19 '07 #1
2 2096
puppydogbuddy
1,923 Recognized Expert Top Contributor
[size=3][font=Times New Roman][color=black]ORDER BY can work with an alias column if you use "order by N" (N - selected item number).

So, the code below should work:

[/color]SELECT Employee, Status as ss
FROM data
[color=black]ORDER BY 2 'the second item in your selection list[/color][/font][/size]
May 19 '07 #2
mindxing
2 New Member
Excellent. Thanks.

_M_
May 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

18
9732
by: war_wheelan | last post by:
I am very new to Transact-SQL programming and don't have a programming background and was hoping that someone could point me in the right direction. I have a SELECT statement SELECT FIXID,...
5
8575
by: Ataru Morooka | last post by:
Hi, my table has to have a column with the months names (january, february...). When I order it by month it is ordered alphabetically and that's not what I need. Reading this ng I found someone...
0
1485
by: Lenny | last post by:
Hello, I have an html table template which I want to turn into ASP.NET custom control. I want to utilize the best features of OOP. I want to be able to create columns headings dynamically, add...
1
3572
by: nate axtell | last post by:
In VB .Net I made a custom CheckBox column style (for the Datagrid control) that maps to two DataTable columns , one it uses for the Checked status and the other it uses for the Enabled status. I am...
2
2417
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
1
4640
by: Thomas Schoen | last post by:
Hi, is it possible to use a parameter of a plpgsql-function to order a selection inside the function? What i would like to do is pass a column-name/alias-name to a plpgsql function and use...
0
3445
by: Pieter | last post by:
Hi, I'm using NHibernate 1.2 (CR1), and I'm using a custom list (inherited from BindingList(Of T) ) for all my lists. The NHibernate documentation told me that I had to implement...
0
1612
by: blitzenn | last post by:
I am attempting to use triggers to add some simple auditing to my database structure (SQL Server 2005). I am running an ASP with this so I have many databases (dozens) with identical structure. My...
1
2101
by: Achtland | last post by:
Hi all, I'm rather new to XSL (and this forum) and have searched everywhere to find out how to order the output of XML to text using XSLT but haven't found the answer. The XML is similar to...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
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...
0
7220
jinu1996
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...
1
6893
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...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
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...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.