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

  • Home
  • SEARCH
  • 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 8124031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:20:49+00:00 2026-06-06T06:20:49+00:00

My Query SELECT DATE, SEC_TO_TIME( SUM( TIME_TO_SEC( `total_hours` ) ) ) AS total FROM

  • 0

My Query

 SELECT DATE, SEC_TO_TIME( SUM( TIME_TO_SEC(  `total_hours` ) ) ) AS total
FROM work_details
WHERE  `employee_id` =  '28'
AND DATE
BETWEEN  '2012-02-01'
AND  '2012-02-29'
GROUP BY DATE
ORDER BY DATE

// Which takes total hours worked for a given employee in given date from database table work_details ,total_hours is of time type.

Result

DATE    total
2012-02-01  04:19:50
2012-02-02  07:38:21
2012-02-06  07:43:24
2012-02-07  07:21:36
2012-02-08  07:38:45
2012-02-09  06:05:22
2012-02-10  07:28:00
2012-02-13  07:37:38
2012-02-14  07:37:22
2012-02-15  07:35:10
2012-02-16  07:29:13
2012-02-17  07:07:23
2012-02-20  07:40:32
2012-02-21  07:43:32
2012-02-22  07:36:40
2012-02-23  07:37:57
2012-02-24  07:35:04
2012-02-27  09:54:02
2012-02-28  07:41:35
2012-02-29  04:01:11

I need to retrieve the dates in which the the total working hours which are < 4 hours,so that i can count that days as half leaves. Any Help ??

I tried this query too, i have given 8 instead of 4,because my table consists no data less than 4 now.

SELECT DATE, SEC_TO_TIME( SUM( TIME_TO_SEC(  `total_hours` ) ) ) AS total, 
CASE WHEN SEC_TO_TIME( SUM( TIME_TO_SEC(  `total_hours` ) ) ) < ( 3600 *8 ) 
THEN 1 
ELSE 0 
END AS half_day
FROM work_details
WHERE  `employee_id` =  '28'
AND DATE
BETWEEN  '2012-02-01'
AND  '2012-02-29'
GROUP BY DATE

Result

DATE    total   half_day
2012-02-01  07:19:50    0
2012-02-02  07:38:21    0
2012-02-06  07:43:24    0
2012-02-07  07:21:36    0
2012-02-08  07:38:45    0
2012-02-09  06:05:22    0
2012-02-10  07:28:00    0
2012-02-13  07:37:38    0
2012-02-14  07:37:22    0
2012-02-15  07:35:10    0
2012-02-16  07:29:13    0
2012-02-17  07:07:23    0
2012-02-20  07:40:32    0
2012-02-21  07:43:32    0
2012-02-22  07:36:40    0
2012-02-23  07:37:57    0
2012-02-24  07:35:04    0
2012-02-27  09:54:02    0
2012-02-28  07:41:35    0
2012-02-29  08:01:11    0
  • 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-06-06T06:20:51+00:00Added an answer on June 6, 2026 at 6:20 am

    Try adding this at the end of the query:

    HAVING HOUR(total) < 4;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For this query SELECT min(date) min_date FROM order_products group by order_id min_date ignores the
I have the following MySQL query: SELECT SUM(IF(num_content>3,3,num_content)) FROM ( SELECT DATE(FROM_UNIXTIME(content_timestamp)) as dt,
I have a query: SELECT ID FROM requests WHERE date <operator> <expression> I need
SQL query: SELECT ArticleCategories.Title AS Category, Articles.Title, Articles.[Content], Articles.Date FROM ArticleCategories INNER JOIN Articles
I have an Rails ActiveRecord group query: a = Product.select(date(date) as date, count(id) as
I have the following sql query : SELECT DATE(procedures.start) date, name, COUNT(procedure_types.id) count FROM
please take a look of this query: SELECT DATE(datetime), COUNT(1) as numVisits FROM .table_stats.
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
i am using this query select date_time_posting from table where FROM_UNIXTIME(date_time_posting,'%d-%m-%Y')='$c_day_date' where $c_day_date is
I have a query like this: select display_order , section_name , solution_section_id from solution_sections

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.