troubleshooting Question

Why is my sum function not working properly?

Avatar of ozzy t
ozzy t asked on
Microsoft SQL ServerSQL
7 Comments1 Solution87 ViewsLast Modified:
I am trying to do a simple sum on the "Booking_Factor" column(int) and it is not summing at all as if nothing , the values are the same, any idea? Thank You.
SELECT distinct 

      RES.Description,
      Available_Date,
      --LOC.Scheduling_Location_ID,
      --DEPT.Description,
      --Day_Type_ID,
      --Available_Time_Block_ID,
      --Available_Time_Block_TS,
      Start_Time,
      End_Time,
      Usual_Appt_Duration,
      SUM(Booking_Factor)AS Capacity
      
     -- AVAILBLOCK.Activity_Type_ID,
     -- ELIG.Appointment_Category_ID AS Elig_Appointment_Category_ID,
     --INELIG.Appointment_Category_ID AS Inelig_Appointment_Category_ID 
   
FROM PM.Available_Days AVAILDAY WITH (NOLOCK)
      LEFT JOIN PM.Available_Time_Blocks AVAILBLOCK WITH (NOLOCK) ON AVAILBLOCK.Available_Day_ID = AVAILDAY.Available_Day_ID
      --LEFT JOIN PM.Scheduling_Locations LOC WITH (NOLOCK) ON LOC.Scheduling_Location_ID = AVAILDAY.Scheduling_Location_ID
      --LEFT JOIN PM.Scheduling_Departments DEPT ON DEPT.Scheduling_Department_ID = AVAILDAY.Scheduling_Department_ID
      LEFT JOIN PM.Resources RES WITH (NOLOCK) ON RES.Resource_ID = AVAILDAY.Resource_ID
      --LEFT JOIN PM.Activity_Elig_Appt_Categs ELIG WITH (NOLOCK) ON ELIG.Activity_Type_ID = AVAILBLOCK.Activity_Type_ID
      --LEFT JOIN PM.Activity_Inelig_Appt_Categs INELIG WITH (NOLOCK) ON INELIG.Activity_Type_ID = AVAILBLOCK.Activity_Type_ID


WHERE AVAILDAY.Available_Date = '2017-03-09'
AND RES.Description = 'REYNOLDS, EUGENE II'


group by
 RES.Description,
 Available_Date,
 Start_Time,
 End_Time,
 Usual_Appt_Duration
 
ASKER CERTIFIED SOLUTION
Vitor Montalvão
IT Engineer
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros