Advertisement

03.25.2008 at 05:53PM PDT, ID: 23269161
[x]
Attachment Details

Trying to do UNION with Order By on both Select statements

Asked by attipa in SQL Server 2005

Tags: SQL

I am trying to do a UNION statement between 2 Select statements where they both will do an Order By first and then give me the top 3 for each....

Select Top 3 BlogID, Headline, [Text], DateAdded, Picture1, Picture1URL, 'Movies' From BlogMovies ORDER BY DateAdded DESC
UNION
Select Top 3 BlogID, Headline, [Text], DateAdded, Picture1, Picture1URL, 'TV' From BlogTV ORDER BY DateAdded DESC

I know the code above doesn't work...but how can I get the 3 most recent blogs for each and combine them together in a UNION statement?Start Free Trial
 
Loading Advertisement...
 
[+][-]03.25.2008 at 06:03PM PDT, ID: 21207952

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 09:16PM PDT, ID: 21208852

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 10:00PM PDT, ID: 21208990

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: SQL
Sign Up Now!
Solution Provided By: appari
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.25.2008 at 10:02PM PDT, ID: 21209002

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 10:07PM PDT, ID: 21209025

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628