Q:

sql count of multiple tables possible inner join

I have a Table called Jobs and 02 other tables (places and times) that connect to Jobs by the JobID.
So, based on the tables below, I need the following in SQL server:
Jobs (JobID,Company)

123     ABC

456     DEF

789     GHI

PLACES (Country,JobID)
BR          123
EU          123
CA          456

TIMES(time,JobID)
05          456

08          123

09          789

Needed query Result:
QRYRESULT(JobID,CountOFPLaces,CountofTimes)

123 ,       2,                      1

456 ,       1 ,                 1

789 ,           ,               1 

Thanks for the help!

A:

There keys here are knowing that using an outer join can give you all results for all jobs and that a count(distinct field)  will give you distinct counts eliminating the additional counts added by joins (assuming each record is unique  and that duplicates don't exist in a given table) 
SELECT J.jobID, 
    count(Distinct P.Country) as CountOfPlaces, 
    Count(Distinct T.Time) as CountOfTimes
FROM Jobs J
LEFT JOIN Places P
 on J.JobID=P.JobID
LEFT JOIN Times T
 on T.JobID = J.JobID
GROUP BY J.JobID

