Records Count

How to count number of records in a table without using COUNT function?

Questions by Subashpanda   answers by Subashpanda

Showing Answers 1 - 21 of 21 Answers

NSingh

  • Dec 21st, 2010
 

In SQL Server you can use this query:- select max(s.sno) from (select row_number() over(order by col_name) as sno from tab_name) s

  Was this answer useful?  Yes

Below are the two alternative methods can be used to get the count of records from table without using count function

Method 1 :

select max(count) from

(select row_number() over (order by 1) count

from emp1)


Method 2 :

select sum(case when empname is null then 1

else 1 end)

from emp1;


  Was this answer useful?  Yes

Sujaya

  • Jun 8th, 2012
 

Simple use the following command:
SELECT COUNT(*) From Emp;

  Was this answer useful?  Yes

smily08

  • Aug 30th, 2012
 

select max(rownum) from
(select ROW_NUMBER() over (order by col_name) as rowNum from table_name)
withRowNum

  Was this answer useful?  Yes

Sandipan

  • Sep 6th, 2012
 

Select sum(1) from emp;

Code
  1. SELECT sum(1) FROM emp;

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions