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,450 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
5 Comments
 
LVL 18

Accepted Solution

by:
SjoerdVerweij earned 500 total points
Comment Utility
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
Comment Utility
thanks, yea, I didn't need all those other fields
0
 
LVL 4

Expert Comment

by:BulZeyE
Comment Utility
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
Comment Utility
Why not just put SELECT TOP 100 Percent ...

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

Author Comment

by:dba123
Comment Utility
thank you all
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now