Home » SQL & PL/SQL » SQL & PL/SQL » Need query help
Need query help [message #21091] Thu, 11 July 2002 20:39 Go to next message
JSlick
Messages: 15
Registered: July 2002
Junior Member
I need some help forming a query over a single table.
This is probably pretty easy to do, but I'm a newbie.

Please consider the following table, which may look a bit squashed.

SEQ PARTID S HOTTIME
--- --------- - ---------
245 222 I .00037037
246 222 I .00005787
247 222 I .00003472
248 222 I .00003472
249 222 O
253 220 I .00591435
254 228 I .03850694
255 226 O
257 227 I .00121528
258 227 I .0000463
259 227 I .00240741
262 227 O

GOAL:

Disregard all rows where S = O.

For each PARTID number where S = I, sum the hottime for that PARTID.

List the sums thus, one row per unique PARTID:

PARTID SUM
------ ----
220 sum
222 sum
227 sum
228 sum
Re: Need query help [message #21093 is a reply to message #21091] Thu, 11 July 2002 22:02 Go to previous messageGo to next message
meena
Messages: 36
Registered: December 2000
Member
the query is

select partid,sum(hottime)
from tablename
where S='I'
group by partid
thx. need to study "group by" [message #21096 is a reply to message #21091] Fri, 12 July 2002 00:22 Go to previous message
JSlick
Messages: 15
Registered: July 2002
Junior Member
No Message Body
Previous Topic: Julian Date??
Next Topic: South African Time
Goto Forum:
  


Current Time: Tue Apr 23 21:18:06 CDT 2024