Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:03:26+00:00 2026-05-23T09:03:26+00:00

Teaching myself SQL, and using an employee info db, on oracle 11g. I’m trying

  • 0

Teaching myself SQL, and using an employee info db, on oracle 11g.

I’m trying to return the total numbers of hours and days worked by an employee at each of the “offices”

However, the “work hours” returns the correct time of each employees shift, but as individual rows, instead of having one row with total number of days and total number of hours. (This means each row has number of days = 1)

SELECT L.OFFICE_NAME as "Shop", 
(us.LAST_NAME || ' , ' || us.FIRST_NAME) AS "Employee Name",
COUNT(distinct shift.shift_date) as "WORK DAYS",
round((shift2.MaxSignOffTime-shift.MinSignOnTime)*24, 1) AS "WORK HOURS",

FROM 
LOCAL_OFFICE L
JOIN 
    Orders ord
    ON L.LOCAL_OFFICE_ID = ord.LOCAL_OFFICE_ID
JOIN  
    USERS us
    ON
     us.USER_ID = ord.ASSIGNED_TO_USER_ID
join
    (SELECT min(act_sign_dt) as MinSignOnTime, USER_ID, shift_token 
FROM CLIENT_SIGN 
WHERE
    BEG_OF_SHIFT = 'Y'
GROUP BY shift_date, user_id, shift_token)  shift on shift. user_id = ord.assigned_to_user_id
join
    (SELECT max(act_sign_dt) as MaxSignOffTime, USER_ID, shift_token 
FROM CLIENT_SIGN 
WHERE
    end_OF_SHIFT = 'Y'
GROUP BY shift_date, user_id, shift_token)  shift2 on shift2.shift_token = shift.shift_token

GROUP BY OFFICE_NAME, LAST_NAME, FIRST_NAME,shift.shift_date, (shift2.MaxSignOffTime-shift.MinSignOnTime)
ORDER BY OFFICE_NAME, "Employee Name"

I’m willing to answer any questions needed, but I simply cannot see why it is not grouping into one row for each employee for each office location

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:03:27+00:00Added an answer on May 23, 2026 at 9:03 am

    Try this…

    Put a Sum() around this in the SELECT:

    round((shift2.MaxSignOffTime-shift.MinSignOnTime)*24, 1)
    

    and remove this:

    (shift2.MaxSignOffTime-shift.MinSignOnTime)
    

    from the GROUP BY clause

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello: I am teaching myself Linq to Sql in C#. Because I am using
I've been teaching myself Spring 3.0 by implementing a JavaEE Web-app using: Tomcat 7
I'm teaching myself XSLT and am still trying to wrap my brain around the
I'm teaching myself some Django tonight using the local dev package at instantdjango.com I
I'm teaching myself OpenGL and I'm implementing ttf text rendering using FreeType 2. I
I'm teaching myself C#, so forgive me if this seems slightly obvious. I'm trying
I'm currently teaching myself Objective-C and Iphone Development using the very good 'Begining IPhone
I have been teaching myself OpenGL programming using the Python wrapper PyOpenGL, and am
I am teaching myself web development, and right now I'm using HTML/CSS/PHP, but I
Im teaching myself java and the book i'm looking at just got around to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.