Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement for adding timeStamp columns

Status
Not open for further replies.

HughbertD

Technical User
Apr 30, 2007
42
0
0
GB
Hi all,

I have a table which holds information for meetings, in the form of, startDate (timestamp), finishDate(timestamp), meetingCompany (varchar).

I want to:

Add up the total amount of time spent in meetings for each different company. But only include meetings that are longer than 2 hours long.

I haven't a clue how to do this, which is why I have come to you guys, I was told that this was possible in SQL but I had my doubts.

If anyone can help I would really appreciate it
 
Code:
select meetingCompany
     , sum(mtg_hrs) as total_hrs
  from ( select time_to_sec(
                timediff(finishDate,startDate)
                           ) / 3600.0 as mtg_hrs
              , meetingCompany                  
           from meetings ) as t
 where mtg_hrs >= 2.0
group
    by meetingCompany

r937.com | rudy.ca
 
Superb.

Thank you so much for taking the time to do that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top