Solved

SQL Query with Subquery

Posted on 2012-03-21
3
245 Views
Last Modified: 2012-08-14
I'm having trouble getting this sql query to work:

SELECT Date, Title FROM (SELECT Date, Title FROM Article WHERE Title LIKE '%US%') WHERE Date BETWEEN '1/1/2012' AND '2/1/2012'

Please advise. Thanks in advance.
0
Comment
Question by:MaxKroy
3 Comments
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 500 total points
ID: 37751119
SELECT Date, Title
FROM
(
  SELECT Date, Title
  FROM Article
  WHERE Title LIKE '%US%'
) X
WHERE Date BETWEEN '1/1/2012' AND '2/1/2012'

Open in new window

0
 

Author Closing Comment

by:MaxKroy
ID: 37751124
Awesome, thanks dale
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37751924
just a  question, why do you need the subquery?  why not just use:

SELECT Date, Title
FROM Article
WHERE Title LIKE '%US%'
AND Date BETWEEN '1/1/2012' AND '2/1/2012'
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to deploy to IIS 7 on 2008R2 server with DUO 2-step login? 2 30
SQL Login 17 37
Help with C#, MVC, razor. 6 18
MS SQL Inner Join - Multiple Join Parameters 2 17
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

948 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

20 Experts available now in Live!

Get 1:1 Help Now