Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

SQL Server - Get Row Count including Column Values in SQL Server

Article:
Viewed:  986 
Posted On:  10/06/2015 21:40:18 
How we can show Row Count including Column Values in SQL Server ? 

 

Some time you need to show Total number of records and column value from a SQL Server table.

Below is my Data Table from which I am reading records:


1.png

Image 1.

Now Select Column from this table:

2.png

Image 2.

Now I want to show one more column which will show Total Number of records in this table.  So First below thought in our mind come:

 

SELECT COUNT(*) AS TotalRecords, EMPLOYEE_ID,NAME,EMAIL,MOBILE,
COUNTRY FROM EMPLOYEETEAM

If you use above query then you will get below error message:

3.png

Image 3.

So the right Query is:

 

SELECT COUNT(*) OVER (PARTITION BY 1) AS TotalRecords, EMPLOYEE_ID, NAME,
EMAIL, MOBILE, COUNTRY FROM EMPLOYEETEAM

4.png

Image 4.

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us