Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Group by where all subrows fullfill the requeriments

Posted on 2009-05-12
2
Medium Priority
?
278 Views
Last Modified: 2012-05-06
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,
0
Comment
Question by:silviall
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 24367528
this should do:
  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' 
      group by c.obra
      having min(fecha_fac)>=@dateini and min(fecha_fac)>=@datafi
         and sum(case when c.factura is null then 1 else 0 end) = 0

Open in new window

0
 
LVL 6

Expert Comment

by:bokist
ID: 24368083
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
 
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question