Home » SQL & PL/SQL » SQL & PL/SQL » Need help in sql query (oracle 10g )
Need help in sql query [message #422831] Sun, 20 September 2009 03:42 Go to next message
vparunaix
Messages: 3
Registered: August 2009
Location: India
Junior Member
Hi Everyone ,
i m a new bee to sql.
I have a below query which returns like this

select count(*),cc,fai from cindata GROUP BY cc,fai;

COUNT(*) CC FAI
---------- -- ----------
3 ab 2
1 ac 6
3 ab 1

I want the sum of count values returned on ROW 1 from this query.
any one help me ?
Re: Need help in sql query [message #422833 is a reply to message #422831] Sun, 20 September 2009 04:11 Go to previous messageGo to next message
_jum
Messages: 577
Registered: February 2008
Senior Member
Your question isn't quit clear for me , do You mean COLUMN 1 ?
The SUM of all Your grouped COUNTS is the number of all rows.

[Updated on: Sun, 20 September 2009 04:11]

Report message to a moderator

Re: Need help in sql query [message #422834 is a reply to message #422831] Sun, 20 September 2009 04:14 Go to previous messageGo to next message
vparunaix
Messages: 3
Registered: August 2009
Location: India
Junior Member
Sorry ,

i want to sum the values in COLUMN 1 i.e returned from count(*)
Re: Need help in sql query [message #422835 is a reply to message #422834] Sun, 20 September 2009 04:29 Go to previous messageGo to next message
_jum
Messages: 577
Registered: February 2008
Senior Member
Use a subquery:
SELECT SUM(cnt) FROM
 (
  SELECT COUNT(*) cnt, cc, fai FROM cindata
    GROUP BY cc, fai
 )

But You will only get the same result as:
  SELECT COUNT(*) FROM cindata


Re: Need help in sql query [message #422837 is a reply to message #422831] Sun, 20 September 2009 05:42 Go to previous message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version with 4 decimals.

Post a working Test case: create table and insert statements along with the result you want with these data.

Regards
Michel
Previous Topic: BFILENAME with filenames containing accents
Next Topic: ORA-02291: integrity constraint
Goto Forum:
  


Current Time: Tue Feb 11 06:42:20 CST 2025