June 25, 2008 at 1:37 pm
Hello Everyone,
I have a table 'employee' with 3 columns, EMPNO, HRS_WRKD, PAYCODE_NAME
This test employee worked 40 hours in REG paycode and 12 hours in OT
I run the following query to get totals on worked paycodes
select EMPNO, sum(HRS_WRKD), PAYCODE_NAME
from employee
I get the following result
EMPNO HRS_WRKD PAYCODE_NAME
1234 40 REG
1234 12 OT
What query I need to run to get the following result?
EMPNO HRS_WRKD
1234 52
Thank You,
June 25, 2008 at 1:44 pm
This:
select EMPNO, sum(HRS_WRKD), PAYCODE_NAME
from employee
Is probably actually:
select EMPNO, sum(HRS_WRKD), PAYCODE_NAME
from employee
group by EMPNO, PAYCODE_NAME
The way to get the second query is get rid of both copies of "PAYCODE_NAME"; both the one in the Select and the one in the Group By.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 25, 2008 at 1:48 pm
Awesome, thanks SSCrazy for such a quick reply, I'm so glad I joined this group 🙂
June 25, 2008 at 1:50 pm
You're welcome.
By the way, "SSCrazy" is a title, because of my number of posts. My name is Gus, and my screen name is "GSquared". It shows up above the post, in the darker-blue row.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 25, 2008 at 2:08 pm
Oops sorry about that Gus (GSquared), I'm a newbie and I know it shows 🙂
Thanks again.
June 30, 2008 at 8:58 am
No problem. Welcome to a great SQL site.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply