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
If you use avobe query then you will get below error message:
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