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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting only "finished" groups

Status
Not open for further replies.

wbodger

Programmer
Apr 23, 2007
769
0
0
US
OK, let's say that I have a table with 5 columns: ID, Name, ProviderId, Date, Amount

Now, let's say that I fill in 4 of the fields and the client has to fill in the fifth field (in this case, ProviderId)

Is there a nice way to ONLY select the Name (they will be grouped by name and date) for those that have filled in ProviderId for ALL records for a given day?

Code:
1, Joe, 123, 3/6/2017, 20
2, Joe, 234, 3/6/2017, 38
3, Joe, , 3/6/2017, 25
4, Jill, 156, 3/6/2017, 40
5, Jill, 321, 3/6/2017, 12

So, I want to select Jill because she did her job and has given me the ProviderId for her transactions, but not Joe, because he did not finish all of them.

Thanks,
Willie
 
Untested:

Code:
SELECT Name, Date FROM yourtable GROUP BY Name, Date Having COUNT(*)=COUNT(ProviderID)

Bye, Olaf.

 
I'm pretty sure it works, it just depends on the gaps being NULL values. An empty field is something COUNT(field) will count, too.

Bye, Olaf.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top