Avatar of asrgrant
asrgrant
 asked on

sum field and Show empty records ( IS NULL) ??

I want have 2 tables: Personnel and Unit_time. Im currently displaying a grid, attached, but want to show the "personnel.surname" that have not added to "unit_time.hour". So i basically want to show a full grid of people including those that have not entered "hours"
-------------------------------------
SELECT personnel.rank, personnel.surname, Sum(unit_time.hours) AS SumOfhours, unit_time.personID, Count(unit_time.personID) AS CountOfpersonID

FROM personnel INNER JOIN unit_time ON personnel.PersonID = unit_time.personID
WHERE unit_time.datestamp  between firstdate AND secdate

GROUP BY personnel.surname, unit_time.personID,personnel.rank
-----------------------------------------

Many Thanks
ee1.gif
Microsoft SQL Server

Avatar of undefined
Last Comment
jogos

8/22/2022 - Mon
jogos

Then it's a left join + condition not in where but in join
SELECT personnel.rank, personnel.surname, Sum(unit_time.hours) AS SumOfhours, unit_time.personID, Count(unit_time.personID) AS CountOfpersonID

FROM personnel
 LEFT  JOIN unit_time ON personnel.PersonID = unit_time.personID
AND unit_time.datestamp  between firstdate AND secdate 

Open in new window

asrgrant

ASKER
Hey changed the join and nothing happened.
asrgrant

ASKER
Just offline back tomorrow. Its 14:38 GMT (ZULU TIME)
MANY THANKS
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
jogos

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question