Select Count(*),* from TourBooking Where MemberID = 6
Giving an error
"Column 'TourBooking.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."
Select Count(*),* from TourBooking Where MemberID = 6
Giving an error
"Column 'TourBooking.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."
You need to use a subselect:
Select (select Count(*) from TourBooking Where MemberID = 6), *
from TourBooking
Where MemberID = 6
count()
is an aggregate function and thus requires a group by
. If you want to count the total number of rows in your result, you can use a window function to add such a column:
select count(*) over () as total_count,
TourBooking.*
from TourBooking
where MemberID = 6;
If you want the total count in the table TourBooking
regardless of the value in the column MemberId
you need a scalar sub-query in order to retrieve the count:
Select (select Count(*) from TourBooking) as total_count,
TourBooking.*
from TourBooking
where MemberID = 6
Please change your code from
Select Count(*),* from TourBooking Where MemberID = 6
into
Select Count(*) from TourBooking Where MemberID = 6