Q:

Grouping by multiple fields

I have a table of ParentID's which are products made by combining the required amount of the corresponding BaseID product. 
Product table:
    ParentID    BaseID    Required    UOH
    -------------------------------------
    1           55        1           400
    1           56        .5          400
    2           55        1           400
    2           57        1           400
    3           58        1           0

I need to  select the ParentID's where there are enough of each required base product (UOH) to create the Parent.
The Query should return 
    ParentID
    ----------------
    1
    2

The only way I know how to do this is by using a pivot view. Is there another or a better way to accomplish this?
Thanks

A:

You can use group by and having:
select parentid
from table t
group by parentid
having sum(case when uoh < required then 1 else 0 end) = 0

The having clause counts the number of times where uoh is less than required.  If the count is zero, then all base ids have sufficient amounts.

