Reputation: 305
I am having follwoing table
student
sid sname branch semester
1 Vijay CSE 6
2 Ajay MECH 4
3 Riteh CSE 6
4 Nutan CSE 6
5 Riya ETC 4
6 Ritu CSE 6
Here I want to fetch all record and total fetched record count for that i am using following query, but this is not able to fetch all records
select *,count(sid) from students
How can we do this
Upvotes: 0
Views: 52
Reputation: 1
Try this.
SELECT TotalRecords=Count(*) OVER(), Sname,Branch,Semester FROM Students
Upvotes: 0
Reputation: 263723
There are many possible solutions for this,
using subquery
select *,(SELECT COUNT(*) FROM students) totalCOunt from students
using CROSS JOIN
select a.*, b.totalCOunt
from students a, (SELECT COUNT(*) totalCOunt FROM students) b
Upvotes: 1