Some time you need to show Total number of records and column value from a SQL Server table.
Below is my Data Table from I am reading records:

Image 1: Reading Record
Now Select Column from this table.

Image 2: Select Column
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

Image 3: Error Messege
So the right Query is
- SELECT COUNT(*) OVER (PARTITION BY 1) AS TotalRecords, EMPLOYEE_ID, NAME,
- EMAIL, MOBILE, COUNTRY FROM EMPLOYEETEAM

Image 4: Output

SubashPosted Aug 22, 2016, 10:37 PM
Nice
Santhakumar MunuswamyPosted Jun 12, 2015, 2:44 PM
Thanks for sharing
Danny SchneiderPosted Jun 12, 2015, 12:48 AM
Nice approach, but what is the query doing at the point of interest? Can you explain what the query dies?