Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jim_jim
Constraint Violating Yak Guru
306 Posts |
Posted - 2012-09-25 : 14:19:19
|
I am trying to write a select statement to get all requests from a table customerinfo where count of the reqno is greater than 1 and in every unique reqno there should be atleaset one reportid with an Id 1873 and the other reportids can be anything between (456,457,458,459,460)Iam not sure how i put sql together for the above but the sample data will look like thisReqno ReportId111111 1873111111 460111111 457222222 1873222222 456333333 456333333 1873333333 460333333 459Thanks |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-09-25 : 14:22:34
|
SELECT ReqNo FROM customerinfo WHERE ReportID=1873INTERSECTSELECT ReqNo FROM customerinfo WHERE ReportID BETWEEN 456 AND 460 |
|
|
jim_jim
Constraint Violating Yak Guru
306 Posts |
Posted - 2012-09-25 : 14:44:19
|
Thank Youquote: Originally posted by robvolk SELECT ReqNo FROM customerinfo WHERE ReportID=1873INTERSECTSELECT ReqNo FROM customerinfo WHERE ReportID BETWEEN 456 AND 460
|
|
|
|
|
|