Home » SQL & PL/SQL » SQL & PL/SQL » Count function (11G)
Count function [message #673953] Wed, 19 December 2018 08:46 Go to next message
ABG
Messages: 5
Registered: April 2018
Junior Member
I know the count function gives count of anything , But recently I have seen it being in the select list like

 select*from t.*
What does it means? I have also seen it being used in the middle of the select list like
select ename,empno,count(*),sum(salary)...
Please explain.
Re: Count function [message #673956 is a reply to message #673953] Wed, 19 December 2018 11:24 Go to previous messageGo to next message
Michel Cadot
Messages: 67144
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

The first statement is invalid.
The second one just compute aggregate values for some groups of rows (here each group with different ename,empno).
Note that as empno is the primary key of EMP table, you have one row in the result set per row in the table (no aggregates then), count(*) will be 1 and sum(sal) just the same than sal.

Database SQL Language Reference, Chapter 5 Functions, Section Aggregate Functions.

Re: Count function [message #673957 is a reply to message #673953] Wed, 19 December 2018 11:44 Go to previous messageGo to next message
BlackSwan
Messages: 26707
Registered: January 2009
Location: SoCal
Senior Member
SQL> select object_type, count(*) from user_objects  group by object_type;

OBJECT_TYPE		  COUNT(*)
----------------------- ----------
PROCEDURE			 1
LOB				 7
TABLE				17
INDEX				15
VIEW				 1
FUNCTION			 1

6 rows selected.

Re: Count function [message #673963 is a reply to message #673956] Wed, 19 December 2018 20:49 Go to previous messageGo to next message
ABG
Messages: 5
Registered: April 2018
Junior Member
Thanks a lot, Yes that was incorrect, I was rather refering to the code I have seen in this forum:
select e.*,max(cc.CC_DATE ) max_cc_date
What does it means, is it all the rows, when we use this kind of notation,please clarify

[Updated on: Wed, 19 December 2018 20:51]

Report message to a moderator

Re: Count function [message #673966 is a reply to message #673963] Thu, 20 December 2018 01:08 Go to previous messageGo to next message
Michel Cadot
Messages: 67144
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

What don't you understand in this? Please clarify.

Re: Count function [message #673970 is a reply to message #673966] Thu, 20 December 2018 03:28 Go to previous messageGo to next message
cookiemonster
Messages: 13894
Registered: September 2008
Location: Rainy Manchester
Senior Member
'select *' means select all columns from the tables in the from clauses.
'select <alias/table name>.*' means select all columns from the specified table.

And if you don't know that you should do a basic SQL course or read a good book on basic SQL.
Re: Count function [message #673985 is a reply to message #673970] Thu, 20 December 2018 10:02 Go to previous message
ABG
Messages: 5
Registered: April 2018
Junior Member
Thanks cookiemonster and Michel.
Previous Topic: Multiple Row Record Insert Into One Field And Email
Next Topic: date conversion
Goto Forum:
  


Current Time: Mon Jun 01 20:48:03 CDT 2020