Hi every one !
Im workin on SQL05, My Question is !
i have a single field "PosId" in the DB,which i use as two fields one as PosId and PosID2 , Even though Both PosID & PosID2 are from the same fields ,i want to sort the PosID in ascending and PosID2 in desc,
This is what i tried , But ???
"SELECT PosID,PosID as PosID2
FROM tableXX
WHERE (condition = 'XX')
ORDER BY PosID ASC,PosID2 DESC"
Can we use two order by in a single select statement ?
Or is there any alternative .
Plz provide me with a valid soln.
Thanks in advance,
3 1462
Hi every one !
Im workin on SQL05, My Question is !
i have a single field "PosId" in the DB,which i use as two fields one as PosId and PosID2 , Even though Both PosID & PosID2 are from the same fields ,i want to sort the PosID in ascending and PosID2 in desc,
This is what i tried , But ???
"SELECT PosID,PosID as PosID2
FROM tableXX
WHERE (condition = 'XX')
ORDER BY PosID ASC,PosID2 DESC"
Can we use two order by in a single select statement ?
Or is there any alternative .
Plz provide me with a valid soln.
Thanks in advance,
I don't know what you're trying to accomplished. But if that's really your requirement, the answer is NO. You can not do it in a single select statement. You can, however, do it using subquery
Something like: - select * from
-
(SELECT PosID,PosID as PosID2
-
FROM tableXX
-
WHERE (condition = 'XX')) YourTableXX
-
ORDER BY PosID ASC,PosID2 DESC
-
-- CK
I don't know what you're trying to accomplished. But if that's really your requirement, the answer is NO. You can not do it in a single select statement. You can, however, do it using subquery
Something like: - select * from
-
(SELECT PosID,PosID as PosID2
-
FROM tableXX
-
WHERE (condition = 'XX')) YourTableXX
-
ORDER BY PosID ASC,PosID2 DESC
-
-- CK
Thanks for your response, Well ! it worked partialy in displaying the same field in the data set but, one should be in ascending and other should be in descending order !
The above code didnt sort the PosID in desc order ?
Could you post some sample data?
If you are sorting the same field in different order, it will not work. Since your POSID will always be equal to POSID2 (since POSID2 is an alias), it will always be sorted by POSID.
-- CK
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joel |
last post by:
Hi,
I incorporated a function in my code that whenever I use a string variable
in an sql statement if the string contains a single quote it will encase it
in double quotes else single quotes.
...
|
by: P. Emigh |
last post by:
By default in more recent versions, Access forms keep users' last sort
request in the "orderby" property. That can slow things down
considerably, especially when the last user has chosen a...
|
by: DFS |
last post by:
Access97:
I opened a report, then opened a small form that floats above it and lets
you choose report fields to sort on (by issuing the OrderBy statement).
Well, apparently OrderBy actually...
|
by: Todd |
last post by:
Hello,
I'm curious if anyone knows of a way (if one exists) to tell a form (in
Access 2002 VBA) to sort on an unbound column of a combo box on the form.
Here's what I want to do:
A combo box...
|
by: Dutchy |
last post by:
Hi there,
After spending several hours trying all I could imagine and search for in
Google I gave up. In a continuous form I want to sort the choosen column by
clicking the header (label) of...
|
by: fecket |
last post by:
The following code is used in my db to change the sort order of the
report to various fields. I want to take this one stage further and
use maybe a Case Select to give 2 or 3 different options to...
|
by: pbd22 |
last post by:
Hi.
I really need some advice on fine-tuning a stored procedure
that is the meat of the search logic on my site. Customers
are allowed to save searches, which dumps the search logic
in a table...
|
by: dhascuba |
last post by:
The @name field can contain a single quote in it such as: Mike O'Grady.
Since this is creating and SQL statement on the server side, it will not process the name if it has a single quote in it. Id'...
|
by: Marc Gravell |
last post by:
Ah right - I just saw your explanation of "Source"; yes - I'd have 2
queries, then:
switch(Source) {
case "File":
viewData.blah = (from t in database.Tags
where t.FileCount != 0
orderby...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
| |