February 21, 2020, 06:23:14 pm
News: IF YOU ARE A MEMBER FROM THE ORIGINAL SITE AND CAN'T LOGIN. POST IN THE FEEDBACK FORUM (AS GUEST) AND AN ADMIN WILL ASSIST YOU TO ACCESS THE SITE!
Pages: [1]   Go Down
Author Topic: Sql help -- group by  (Read 2057 times)
simmo
Administrator
*

Stars: +3/-0
Offline Offline

Gender: Male
Posts: 8545



« on: October 04, 2005, 02:19:52 pm »

I have a query that returns:
employee, company, hours
but the employee can do multiple jobs for a company so I want to combine them in the query... I know there is a way to do this be am having a problem remembering....

I want this:
john doe, galahtech, 8
john doe, galahtech, 8
john doe, galahtech, 8
john doe, smackteria, 8
john doe, smackteria, 8
don joe, galahtech, 8
don joe, galahtech, 8
don joe, galahtech, 8
don joe, galahtech, 8

to be like this:
john doe, galahtech, 24
john doe, smackteria, 16
don joe, galahtech, 24

any help?
« Last Edit: October 04, 2005, 02:26:15 pm by msimmons » Logged

                 ..... .....

simmo
Administrator
*

Stars: +3/-0
Offline Offline

Gender: Male
Posts: 8545



« Reply #1 on: October 04, 2005, 02:25:49 pm »

Why is it that I remember as soon as I post?

Group by doh

select
  employee,
  company,
  [span style=\'color:blue\']sum([/span]hours[span style=\'color:blue\'])[/span]
from
 tables
where
 whatever
[span style=\'color:blue\']GROUP BY[/span]
 employee,
 company
order by
 employee
Logged

                 ..... .....

Pages: [1]   Go Up
Print
 
Jump to: