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 8617439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:51:30+00:00 2026-06-12T05:51:30+00:00

I’m having a problem in grouping and sorting data in our daily time record

  • 0

I’m having a problem in grouping and sorting data in our daily time record
to automatically produce a report.
The table structure of the DTR as follows:

Log Date    Log Time    Employee Name           Log Type
9/13/2012   17:00:00    SALITA, LYNYRD ANTONIO  LOGOUT
9/13/2012   8:05:00     SALITA, LYNYRD ANTONIO  LOGIN
9/12/2012   17:05:00    SALITA, LYNYRD ANTONIO  LOGOUT
9/12/2012   8:05:00     SALITA, LYNYRD ANTONIO  LOGIN
7/10/2012   17:00:00    GARCIA, ALVIN           LOGOUT
7/10/2012   17:00:00    AURENO, LEAH            LOGOUT
7/10/2012   17:00:00    SALITA, LYNYRD ANTONIO  LOGOUT
7/10/2012   17:00:00    CANSINO, PAUL           LOGOUT
7/10/2012   17:00:00    BELO, RIO               LOGOUT
7/10/2012   17:00:00    MAG-ISA, MAYBELLE       LOGOUT
7/10/2012   17:00:00    TARINE, KAREN           LOGOUT
7/10/2012   17:00:00    REYES, ANDREA           LOGOUT
7/10/2012   17:00:00    NAVARRO, KRISTINA       LOGOUT
7/10/2012   10:30:00    MAG-ISA, MAYBELLE       LOGIN
7/10/2012   8:00:00     SALITA, LYNYRD ANTONIO  LOGIN
7/10/2012   8:00:00     CANSINO, PAUL           LOGIN
7/10/2012   8:00:00     BELO, RIO               LOGIN
7/10/2012   7:40:00     AURENO, LEAH            LOGIN
7/10/2012   7:30:00     GARCIA, ALVIN           LOGIN
7/10/2012   7:25:00     TARINE, KAREN           LOGIN
7/10/2012   7:10:00     NAVARRO, KRISTINA       LOGIN
7/10/2012   7:10:00     REYES, ANDREA           LOGIN

I want it to be processed as a query with an output like this:

Log Date    Employee Name           LOGIN       LOGOUT
9/13/2012   SALITA, LYNYRD ANTONIO  8:05:00     17:00:00
9/12/2012   SALITA, LYNYRD ANTONIO  8:05:00     17:05:00
7/10/2012   GARCIA, ALVIN           7:30:00     17:00:00
7/10/2012   AURENO, LEAH            7:40:00     17:00:00
7/10/2012   SALITA, LYNYRD ANTONIO  8:00:00     17:00:00
7/10/2012   CANSINO, PAUL           8:00:00     17:00:00
7/10/2012   BELO, RIO               8:00:00     17:00:00
7/10/2012   MAG-ISA, MAYBELLE       10:30:00    17:00:00
7/10/2012   TARINE, KAREN           7:25:00     17:00:00
7/10/2012   REYES, ANDREA           7:10:00     17:00:00
7/10/2012   NAVARRO, KRISTINA       7:10:00     17:00:00

How do I achieve this?

  • 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-12T05:51:31+00:00Added an answer on June 12, 2026 at 5:51 am

    This is what you are trying to get:

    SELECT DATE_FORMAT(LogDate, '%d/%c/%Y') AS LogDate, EmployeeName,
       (GROUP_Concat(CASE LogType WHEN 'LOGIN' THEN LogTime END)) AS LOGIN,
       (GROUP_Concat(CASE LogType WHEN 'LOGOUT' THEN LogTime END)) AS LOGOUT
    FROM myTable
    GROUP BY LogDate, EmployeeName
    ORDER BY LogDate desc;
    

    See this SQLFiddle

    Description of the query:

    Use CASE Statement to convert row to column (for Login and Logout)

    SELECT DATE_FORMAT(LogDate, '%d/%c/%Y') AS LogDate, EmployeeName,
       (CASE LogType WHEN 'LOGIN' THEN LogTime END) AS LOGIN,
       (CASE LogType WHEN 'LOGOUT' THEN LogTime END) AS LOGOUT
    FROM myTable
    GROUP BY LogDate, EmployeeName, LogTime
    ORDER BY LogDate desc;
    

    But this will result you like in this SQLFiddle.

    So you need to use GROUP_CONCAT (MySQL) to join LogTime with NULL and remove LogTime from GROUP BY clause.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.