Solved

Error with Order by

Posted on 2011-02-10
3
261 Views
Last Modified: 2012-05-11
select Distinct -1 as InvestigatorID, Ltrim(Rtrim(p.Name)) as InvestigatorName
Order by p.Name
I get the following error.  How can I fix this?  Thank you.
ORDER BY items must appear in the select list if the statement contains a UNION, INTERSECT or EXCEPT operator.
0
Comment
Question by:lapucca
3 Comments
 
LVL 8

Accepted Solution

by:
pdd1lan earned 500 total points
ID: 34864088
select Distinct -1 as InvestigatorID, Ltrim(Rtrim(p.Name)) as InvestigatorName
Order by  InvestigatorName
0
 

Author Closing Comment

by:lapucca
ID: 34864130
Ah, great.  Thanks.
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 34864145
Order by 2

2 represents the second column...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Select in Access 2003 3 28
MYSQL responding very slow 3 27
too many installs coming along with SQL 2016? 1 18
shrink table after huge delete 2 17
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question