Link to home
Start Free TrialLog in
Avatar of silviall
silviall

asked on

Group by where all subrows fullfill the requeriments

Hello,

I have this select

                      select c.obra, sum(d.importe)
      from d_albven d inner join c_albven c
                     on d.numero=c.numero and d.empresa=c.empresa
      where d.familia<>'HO' and c.factura is not null
      group by c.obra
      having min(fecha_fac)>=@dateini and min(fecha_fac)>=@datafi

But I want better select to extract only the c.obra where all the factura is not null, if there is a row where the factura is null then the c.obra doesn't must apper.

Best regards,
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
perhaps this will work

select c.obra, sum(d.importe)
  from d_albven d,  c_albven c
where d.numero=c.numero
    and d.empresa=c.empresa
    and c.obra is not null
    and d.familia<>'HO'
 group by c.obra
having min(fecha_fac)>=@dateini
           and min(fecha_fac)>=@datafi