Maybe this will do what you want:

SELECT Status.ConFK, LastHours.AppHours;
    FROM Status ;
    INNER JOIN (SELECT ConFK, MAX(Date) AS MaxDate;
        FROM Status;
        GROUP BY ConFK) M ON Status.ConFK = M.ConFK AND Status.Date = M.MaxDate ;
    AND Type = "Approved";
LEFT JOIN (SELECT Hours.ConFK, Hours.AppHours;
            FROM Hours;
            INNER JOIN (SELECT ConFK, MAX(date) AS MaxHoursDate;
                            FROM Hours;
                            GROUP BY ConFK) MH ;
                        ON Hours.ConFK = MH.ConFK AND Hours.Date = MH.MaxHoursDate ) LastHours ;
            ON Status.ConFK = LastHours.ConFK

Frank.

Frank Cazabon

On 21/06/2018 02:28 PM, Ken Dibble wrote:
At 02:21 PM 6/21/2018, you wrote:
What's your expected output from the data you presented?

Answer: 2 Approved Consumers, having a total of 12 Hours.

I did include that in my original post.

To make it a little easier for people to try to help, here's some code to build up the data and my attempt at what I've understood as your requirements:

[snip]

Thank you for doing that. Wow, I'm sorry I omitted that. I usually do that when I ask for help with queries.

Ken

[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to