Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help on query with criterias

Status
Not open for further replies.
Feb 4, 2009
137
US
I have a query join from 3 tables...results on this query range from 3/1/09 to 3/1/11:

EstCode EstName EstType VioNum Date
340 EstA 10 2 3/1/09
340 EstA 10 2 5/5/09
340 EstA 10 2 6/9/10
340 EstA 10 2 12/7/10
341 EstB 11 5 3/28/10
341 EstB 11 5 12/2/10
341 EstB 11 5 2/28/11
345 EstC 10 1 3/8/10
345 EstC 10 7 3/8/10
347 EstD 8 8 5/8/10
347 EstD 8 1 5/8/10
Then now, I would like to show on the report within a date range (2 years). If any est.Code has greater than 3 times on the vioNum or if any estCode has 2 different vioNum during this range then show records on the report.

So based on the result above, the report will be showed:

EstCode EstName EstType VioNum
340 EstA 10 2
345 EstC 10 1
345 EstC 10 7
347 EstD 8 8
347 EstD 8 1
Please help with this, I'm so appreciated.
Thank you very much.

 


hi,
Code:
SELECT EstCode, EstName, EstType, VioNum

FROM [Table1]

Where  EstCode in 
(
Select  EstCode From [Table1] Group By  EstCode Having COUNT(*)>3
) 
OR  EstCode&EstType in
(
Select  EstCode&EstType From [Table1] Group By  EstCode, EstType Having COUNT(*)=2
)

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top