Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
nachopolo
Starting Member
4 Posts |
Posted - 2011-04-01 : 08:09:13
|
| Hello guys,I have a table [TAB12](TASK, NAME, HOURS, DATE) where:TASK: Piece of workNAME: Name of the employeeDATE: When the employee has worked on a certain taskHOURS: Number of hours spent in order to complete the taskI get a lot of entries with the same TASK, NAME and DATE but different amount of HOURS all the time, that's why I need a query where I can generate (in a less number of rows) a summation of all these HOURS entered who share the same other fields (TASK, NAME and DATE).This is my try, but It won't work...SELECT TASK, NAME, DATE, SUM(HOURS)FROM TAB12GROUP BY TASK, NAME, DATEAny ideas?? Thanks in advance guys.. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-04-01 : 09:16:32
|
| What did you mean by it won't work? What is the datatype of HOURS?MadhivananFailing to plan is Planning to fail |
 |
|
|
nachopolo
Starting Member
4 Posts |
Posted - 2011-04-04 : 03:11:19
|
| Hello madhivanan,HOURS is a numeric type of data.What I meant by saying "It won't work" is that when I'm executing the code, it's giving me this error:ORA-00920: invalid relational operator.For this code:SELECT TASK, NAME, DATE, SUM(HOURS)FROM TAB12GROUP BY TASK, NAME, DATEHAVING SUM(HOURS)Seriously I'm about throwing my pc out of the window... |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-04-04 : 03:41:36
|
This is a MICROSOFT SQL Server forum. Try over at dbforums.com for your Oracle questions. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-04-04 : 03:42:48
|
quote: Originally posted by nachopolo SELECT TASK, NAME, DATE, SUM(HOURS)FROM TAB12GROUP BY TASK, NAME, DATEHAVING SUM(HOURS)
And what is your condition with HAVING clause? What is it supposed to be compared with? N 56°04'39.26"E 12°55'05.63" |
 |
|
|
nachopolo
Starting Member
4 Posts |
Posted - 2011-04-04 : 06:27:39
|
| Is it totally necessary to set the condition? iF It is so, let's say ">0". I just want the summation of HOURS for the same TASK, NAME AND DATE.It's a SQL Query made with Navicat Premium... |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-04-04 : 06:53:12
|
If you don't need to HAVING part, leave it out!SELECT TASK, NAME, DATE, SUM(HOURS)FROM TAB12GROUP BY TASK, NAME, DATE N 56°04'39.26"E 12°55'05.63" |
 |
|
|
nachopolo
Starting Member
4 Posts |
Posted - 2011-04-05 : 05:08:07
|
| Thanks Peso! |
 |
|
|
|
|
|
|
|