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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:14:20+00:00 2026-06-18T12:14:20+00:00

I have a table that I am trying run reports on. Problem is that

  • 0

I have a table that I am trying run reports on. Problem is that when the same session_id is used it only selects the first timestamp for all the records.

This is my result set :

+------------+-----------+---------+---------+------------------+---------------+----------+---------------------+----------+
| session_id | anum      | first   | last    | counselor        | why           | start    | Time With Counselor | total    |
+------------+-----------+---------+---------+------------------+---------------+----------+---------------------+----------+
|        215 | A00000000 | rixhers | jdjdjdh | Christine McGraw | Appeal        | 00:02:20 | 00:00:04            | 00:02:24 |
|        216 | B00000000 | rixhers | jdjdjdh | Dawn Lowe        | Loan Question | 00:00:05 | 00:00:03            | 00:00:08 |
|        217 | D00000000 | forthis | isatest | Cherie McMickle  | Loan Question | 00:02:08 | 00:00:02            | 00:02:10 |
|        218 | A00000000 | rixhers | jdjdjdh | John Ivankovic   | Tap Question  | 00:00:42 | 00:00:01            | 00:00:43 |
|        218 | A00000000 | rixhers | jdjdjdh | Christine McGraw | Tap Question  | 00:00:42 | 00:00:01            | 00:00:43 |
|        218 | A00000000 | rixhers | jdjdjdh | Tootie           | Tap Question  | 00:00:42 | 00:00:01            | 00:00:43 |
|        218 | A00000000 | rixhers | jdjdjdh | Front-Kiana      | Tap Question  | 00:00:42 | 00:00:01            | 00:00:43 |
+------------+-----------+---------+---------+------------------+---------------+----------+---------------------+----------+
7 rows in set (0.00 sec)

notice the session_id 218 has the same timestamp for all of the records.

I group by the Primary keys (session_id, Counselor) because each counselor can work on one session so the timestamp must be different for all.

This is my query :

SELECT   
session.session_id,   
session.anum,   
student.first,   
student.last,   
c.counselor, 
session.why, 
SEC_TO_TIME(TIMEDIFF(t.start, session.signintime)) as start,   
SEC_TO_TIME(TIMEDIFF(t.fin, t.start)) AS 'Time With Counselor',   
SEC_TO_TIME(TIMEDIFF(t.fin, session.signintime)) AS total  
FROM session  
INNER JOIN student
    ON student.anum = session.anum   
LEFT JOIN (SELECT support.session_id, support.starttime AS start, support.finishtime AS fin FROM support GROUP BY support.session_id, support.cid) AS t  
    ON t.session_id = session.session_id    
INNER JOIN (select support.session_id, support.cid, counselors.counselor FROM support INNER JOIN counselors ON counselors.cid = support.cid group by support.session_id, support.cid) AS c 
    ON c.session_id = session.session_id 
WHERE session.status = 3
GROUP BY c.session_id, c.cid;

Am I missing something simple here guys/gals?

Thanks,
-RaGe

Edit Number 1 :

mysql> SELECT * from support WHERE session_id = 218;
+------------+-----+---------------------+---------------------+-------------------+
| session_id | cid | starttime           | finishtime          | counselorcomments |
+------------+-----+---------------------+---------------------+-------------------+
|        218 |   1 | 2013-02-06 13:26:40 | 2013-02-06 13:26:41 |                   |
|        218 |   2 | 2013-02-06 13:26:45 | 2013-02-06 13:26:48 | done              |
|        218 |   5 | 2013-02-06 13:26:25 | 2013-02-06 13:26:28 | v                 |
|        218 |   8 | 2013-02-06 13:26:34 | 2013-02-06 13:26:36 |                   |
+------------+-----+---------------------+---------------------+-------------------+
4 rows in set (0.00 sec)

Edit Number 2 :

mysql> SELECT * FROM session;
+------------+-----------+---------------+---------+---------------------+-----------------+--------+
| session_id | anum      | why           | aidyear | signintime          | studentcomments | status |
+------------+-----------+---------------+---------+---------------------+-----------------+--------+
|        215 | A00000000 | Appeal        | 12-13   | 2013-02-06 09:01:45 |                 |      3 |
|        216 | B00000000 | Loan Question | 12-13   | 2013-02-06 09:14:10 |                 |      3 |
|        217 | D00000000 | Loan Question | 12-13   | 2013-02-06 09:14:57 |                 |      3 |
|        218 | A00000000 | Tap Question  | 12-13   | 2013-02-06 13:25:58 |                 |      3 |
+------------+-----------+---------------+---------+---------------------+-----------------+--------+
4 rows in set (0.00 sec)

One session has many support tickets if needed. also this is a picture Of My schema

Edit Number 3 :

SELECT   
s.session_id,   
s.anum,   
st.first,   
st.last,   
c.counselor, 
s.why, 
SEC_TO_TIME(TIMEDIFF(sup.starttime, s.signintime)) as start,   
SEC_TO_TIME(TIMEDIFF(sup.finishtime, sup.starttime)) AS 'Time With Counselor',   
SEC_TO_TIME(TIMEDIFF(sup.finishtime, s.signintime)) AS total  
FROM session s 
INNER JOIN student st
    ON st.anum = s.anum 
INNER JOIN support sup
    ON s.session_id = sup.session_id
INNER JOIN counselors c
    ON sup.cid = c.cid
WHERE s.status = 3
ORDER BY s.session_id asc;

+------------+-----------+---------+---------+------------------+---------------+----------+---------------------+----------+
| session_id | anum      | first   | last    | counselor        | why           | start    | Time With Counselor | total    |
+------------+-----------+---------+---------+------------------+---------------+----------+---------------------+----------+
|        215 | A00000000 | rixhers | jdjdjdh | Christine McGraw | Appeal        | 00:02:20 | 00:00:04            | 00:02:24 |
|        216 | B00000000 | rixhers | jdjdjdh | Dawn Lowe        | Loan Question | 00:00:05 | 00:00:03            | 00:00:08 |
|        217 | D00000000 | forthis | isatest | Cherie McMickle  | Loan Question | 00:02:08 | 00:00:02            | 00:02:10 |
|        218 | A00000000 | rixhers | jdjdjdh | Tootie           | Tap Question  | 00:00:27 | 00:00:03            | 00:00:30 |
|        218 | A00000000 | rixhers | jdjdjdh | Front-Kiana      | Tap Question  | 00:00:36 | 00:00:02            | 00:00:38 |
|        218 | A00000000 | rixhers | jdjdjdh | John Ivankovic   | Tap Question  | 00:00:42 | 00:00:01            | 00:00:43 |
|        218 | A00000000 | rixhers | jdjdjdh | Christine McGraw | Tap Question  | 00:00:47 | 00:00:03            | 00:00:50 |
+------------+-----------+---------+---------+------------------+---------------+----------+---------------------+----------+
7 rows in set (0.00 sec)
  • 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-18T12:14:21+00:00Added an answer on June 18, 2026 at 12:14 pm

    Try running this query removed all the “goodness” that made the query look like a hot beast and got her down to everything that you actually needed. I suggest naming the columns something appropriate.

    SELECT   
    s.session_id,   
    s.anum,   
    st.first,   
    st.last,   
    c.counselor, 
    s.why, 
    SEC_TO_TIME(TIMEDIFF(sup.starttime, s.signintime)) as start,   
    SEC_TO_TIME(TIMEDIFF(sup.finishtime, sup.starttime)) AS 'Time With Counselor',   
    SEC_TO_TIME(TIMEDIFF(sup.finishtime, s.signintime)) AS total  
    FROM session s 
    INNER JOIN student st
        ON st.anum = s.anum 
    INNER JOIN Support sup
        ON s.session_id = sup.session_id
    INNER JOIN Counselors c
        ON sup.cid = c.cid
    WHERE s.status = 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to solve an interesting problem. I have a table that has,
I'm trying to understand a problem I have run into that I don't believe
I'm trying to normalize a mysql database.... I currently have a table that contains
I have a data.frame and I'm trying to create a frequency table that shows
I have a heap based table in MySQL that I am trying to update
I have a MySQL table containing a listing of events that I am trying
I'm trying to have a simple html table, that highlights a row as a
I have a table that has a date/time field and am trying to figure
I have a table that I'm trying to populate based on the values of
I have page process that I am trying to run that will send an

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.