Home » SQL & PL/SQL » SQL & PL/SQL » group by range (oracle 9i)
icon2.gif  group by range [message #315671] Tue, 22 April 2008 06:30 Go to next message
durai
Messages: 38
Registered: December 2006
Member
select * from emp;
Emp_id  Emp_name   Work_class
------- --------   ----------
001     AAA        01
002     BBB        01
003     CCC        02
004     DDD        03
005     EEE        04
006     FFF        04
007     GGG        05



i need output like below
count of work_class 01-02 as 3
count of work_class 03-04 as 3
count of work_class above 04 as 1

i mean i want to group it by work class(range 01-02, 03-04, above 04)

is it possible to get the above result using plain sql(Not by PL/SQL)

Thanx in advance
Re: group by range [message #315680 is a reply to message #315671] Tue, 22 April 2008 06:54 Go to previous message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Yes, it is possible, use DECODE or, easier, CASE to define groups.

Regards
Michel
Previous Topic: storing the value into a variable in a stored procedure
Next Topic: NOT NULL check in function
Goto Forum:
  


Current Time: Sat Feb 08 06:26:25 CST 2025