Q:

Inner join with 3 tables and 2 sum groups

I have 3 tables; COMPANY, TRAINING TICKET and TEST. 
COMPANY table:
 COMPANY CODE | COMPANY NAME
 192            ABC ENTERPRISE
 299            XYZ ENTERPRISE

TRAINING TICKET table:
 TICKET ID | COMPANY CODE | START DATE
 2900            192           2015-02-02
 3939            192           2015-03-03
 4399            299           2015-03-02

TEST SESSION table:
 TEST CODE | TICKET ID | COMPANY CODE | CERTIFIED
 1221        2900            192            YES
 2821        3939            192            NULL
 3922        4399            299            YES

I need something like this:
 C. CODE | COMPANY NAME | 1ST START DATE | TRAINING TICKET TOTAL | CERTIFIED TOTAL
 192      ABC ENTERPRISE  2015-02-02             2                1
 299      XYZ ENTERPRISE  2015-03-02             1                1 

Its possible? 
My Sql instruction is:
Select *, count(TICKET.CCODE) AS TICKET_TOTAL, count(TEST.CODE) AS CERT_TOTAL
from TICKET 
Inner Join COMPANY on TICKET.CCODE = COMPANY.CCODE 
Inner Join TEST on COMPANY.CCODE = TEST.CCODE 
Group by (TICKET.CCODE),(TEST.CCODE)
Order by TICKET_TOTAL DESC

but both counts are always equals (same result for TICKET_TOTAL and CERT_TOTAL) and the sums are wrong - the result is TICKET_TOTAL = 21 and CERT_TOTAL = 28, but I got 523 - for TOP 1 company. 

A:

I got the answer:
Select COMPANY.CODE, COMPANY.NAME, 
MIN(TICKET.STARTDATE), count(TICKET.TICKETID) AS TICKET_TOTAL, 
count(TEST.CERTIFIED) AS CERT_TOTAL
    from COMPANY
    INNER JOIN TICKET ON COMPANY.CODE = TICKET.CCODE 
    LEFT JOIN TEST ON TICKET.TICKETID = TEST.TICKET
    Group by (TICKET.CCODE)
    ORDER BY TICKET_TOTAL DESC 

1- Reorder and star the instruction from COMPANY TABLE
2- MIN(TICKET.STARTDATE) to got the First Start Date (Use MAX to got the Last Start Date if necessary)
3- Change Inner Join to Left Join (because some companies have a ticket on ticket table but does not have a test on test table)
Hope this can help someone in the future!