Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Query with Subquery

Posted on 2012-03-21
3
Medium Priority
?
253 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
[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
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 48

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

721 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