Home » SQL & PL/SQL » SQL & PL/SQL » query modification require
query modification require [message #255928] Thu, 02 August 2007 07:38 Go to next message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
Hi,

i have wrote following query


select DEPARTMENT_ID,count(*),sum(count(*)) over()  
from employee 
where DEPARTMENT_ID is not null group by DEPARTMENT_ID


output is as

20,3,19
50,5,19
60,3,19
80,3,19
90,2,19
100,1,19
110,2,19


i am looking output like


20,3,3
50,5,8
60,3,11
80,3,14
90,2,16
100,1,17
110,2,19



Please sugegst me ..


Yash

[Updated on: Thu, 02 August 2007 08:00] by Moderator

Report message to a moderator

Re: query modification require [message #255931 is a reply to message #255928] Thu, 02 August 2007 07:42 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
change over () to over (order by department_id)
Re: query modification require [message #255932 is a reply to message #255928] Thu, 02 August 2007 07:45 Go to previous messageGo to next message
joy_division
Messages: 4644
Registered: February 2005
Location: East Coast USA
Senior Member
select DEPARTMENT_ID,count(*),sum(count(*)) over(order by DEPARTMENT_ID)
from employee where DEPARTMENT_ID is not null group by DEPARTMENT_ID


Frank beat me to it while I was eating and typing at the same time.

[Updated on: Thu, 02 August 2007 07:46]

Report message to a moderator

Re: query modification require [message #255937 is a reply to message #255932] Thu, 02 August 2007 07:56 Go to previous message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
Thx for replay Frank and joy_division.
Previous Topic: Mutating
Next Topic: How to find records with CR within VARCHAR2
Goto Forum:
  


Current Time: Sun Dec 11 08:16:47 CST 2016

Total time taken to generate the page: 0.08515 seconds