Solved

Error: The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified.

Posted on 2004-07-30
5
1,478 Views
Last Modified: 2007-12-19
SELECT MaxDate = MAX(Start_Date), EndDate = MIN(End_Date) FROM Query_Registration where start_date IN (Select Registration_ID, Course_ID, Course_Number, Course_Name, Class_ID, Start_Date, End_Date, User_ID, FName + ' ' + LName AS Name, Company_Name, Address1, Address2, City, State, Zip, Country, CC_Name, Price, Payment_Type_ID, Payment_Type_Name, CC_Type, CC_Approval_Code, CC_Amount, PO_Amount, PO_Number, Discount_Percent, Date_Paid FROM Query_Registration WHERE Course_ID IS NOT NULL AND Paid = 1 AND (PO_Amount IS NOT NULL OR CC_Amount IS NOT NULL) AND Payment_Type_ID IN (4) AND Start_Date > '7/16/2004' ORDER BY FName, Start_Date)) ORDER BY MaxDate

The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified.
0
Comment
Question by:dba123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 18

Accepted Solution

by:
SjoerdVerweij earned 500 total points
ID: 11680985
SELECT MaxDate = MAX(Start_Date), EndDate = MIN(End_Date) FROM Query_Registration where start_date IN (Select Start_Date FROM Query_Registration WHERE Course_ID IS NOT NULL AND Paid = 1 AND (PO_Amount IS NOT NULL OR CC_Amount IS NOT NULL) AND Payment_Type_ID IN (4) AND Start_Date > '7/16/2004') ORDER BY MaxDate
0
 
LVL 1

Author Comment

by:dba123
ID: 11680992
thanks, yea, I didn't need all those other fields
0
 
LVL 4

Expert Comment

by:BulZeyE
ID: 11680993
I'm not sure what you are trying to do.  Using the IN clause your sql query should only be selecting a single column to compare  the start_date to.  and.... well it is really hard to see what you are actually trying to do without some explaination.
0
 
LVL 9

Expert Comment

by:crescendo
ID: 11681035
Why not just put SELECT TOP 100 Percent ...

That's all it's asking for.
0
 
LVL 1

Author Comment

by:dba123
ID: 11681051
thank you all
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

739 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