Home » SQL & PL/SQL » SQL & PL/SQL » need query help
need query help [message #251329] Fri, 13 July 2007 00:10 Go to next message
bhoite_amol83
Messages: 110
Registered: June 2005
Location: Pune
Senior Member
Hi,

I need a query which will display row values into column values.

Here is the structure of the table.
Create table temp (id number, Grade varchar2(10));

Table values are....

id Grade
1 A
2 A
3 C
4 D
5 B
6 B
7 A
8 B

I need output like the following way.
The result will be of the total count of the id with respect to the grade.

A B C D
3 3 1 1

Can anyone please send me query about it.

Thanks in advance.

[Updated on: Fri, 13 July 2007 00:11]

Report message to a moderator

Re: need query help [message #251330 is a reply to message #251329] Fri, 13 July 2007 00:11 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
What have you tried so far?
Re: need query help [message #251331 is a reply to message #251330] Fri, 13 July 2007 00:33 Go to previous message
bhoite_amol83
Messages: 110
Registered: June 2005
Location: Pune
Senior Member
Hi,

I tried in this way,

SELECT  (SELECT COUNT(id)
		 FROM   temp
		 WHERE  grade = 'A') a,
		 (SELECT COUNT(id)
		 FROM   temp
		 WHERE  grade = 'B') b,
		 (SELECT COUNT(id)
		 FROM   temp
		 WHERE  grade = 'C') c
FROM temp
WHERE ROWNUM = 1;


But the problem is Grade are not fixed they may be vary...
They may be G, K , LK, GH, IO etc.....

So i need some dynamic query.
Thanks in advance.

[Updated on: Fri, 13 July 2007 00:33]

Report message to a moderator

Previous Topic: can a CASE is included in Where Clause.....
Next Topic: Bulk process with limit advice
Goto Forum:
  


Current Time: Sat Dec 10 03:20:09 CST 2016

Total time taken to generate the page: 0.07421 seconds