Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Query with Subquery

Posted on 2012-03-21
3
Medium Priority
?
256 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 2000 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 49

Expert Comment

by:Dale Fye
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

886 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