Solved

Need a Quick SQL Query

Posted on 2011-02-22
4
245 Views
Last Modified: 2012-05-11
One Table called Orders.

ORDERID, ORDERDATE, SHIPSTREET, SHIPCITY, SHIPZIPCODE

I need to return all fields where
ORDERDATE BETWEEN  #1/1/2011# and #1/31/2011#
AND
COUNT(SHIPSTREET) > 1

Thanks

0
Comment
Question by:LanBuddha
  • 2
4 Comments
 
LVL 18

Expert Comment

by:sventhan
ID: 34954913
select ORDERID, ORDERDATE, SHIPSTREET, SHIPCITY, SHIPZIPCODE
from orders
where ORDERDATE BETWEEN  '2011-01-01' and '2001-01-13'  
and count(shipstreet) > 1
0
 
LVL 18

Expert Comment

by:sventhan
ID: 34954932
select ORDERID, ORDERDATE, SHIPSTREET, SHIPCITY, SHIPZIPCODE
from orders
where ORDERDATE BETWEEN  '2011-01-01' and '2001-01-13'  
group by ORDERID, ORDERDATE, SHIPCITY, SHIPZIPCODE
having count(shipstreet) > 1
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 34954990
if you will run this in access


SELECT  OrderID, OrderDate, ShipStreet, ShipCity,ShipZipCode
FROM Orders
WHERE (((ShipStreet) In (SELECT [ShipStreet] FROM [Orders] As Tmp GROUP BY [ShipStreet] HAVING Count(*)>1 )) AND ((OrderDate) Between #1/1/2011# And #1/31/2011#))

0
 
LVL 2

Author Closing Comment

by:LanBuddha
ID: 34955104
Access chokes a little on this but return a result.

thanks much.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OSQL to execute sql command 26 24
SQL USE DATABASE VARIABLE 5 27
SQL Availablity Groups List 2 7
Shrink multiple databases at once 4 20
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

808 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