This question focus to the COUNT result
1st query will show the COUNT with date condition.
2nd query will show the COUNT without date condition.
Now I need a query which make the COUNT result in 1st query without date condition which is :
COUNT(c.CustomerID) > ONLY with condition b.BookingCustomerID=c.CustomerID
(without date condition)
c.CustomerTelephone, b.* > with condition WHERE b.BookingCustomerID=c.CustomerID
AND BookingDate LIKE '%2019-05-04%'
Thanks.
SELECT COUNT(c.CustomerID), c.CustomerTelephone, b.*
FROM Booking b, Customer c
WHERE b.BookingCustomerID=c.CustomerID
AND BookingDate LIKE '%2019-05-04%'
GROUP BY c.CustomerID
SELECT COUNT(c.CustomerID), c.CustomerTelephone, b.*
FROM Booking b, Customer c
WHERE b.BookingCustomerID = c.CustomerID
GROUP BY c.CustomerID
Best Answer
When doing a
GROUP BY
, it is improper to list anything other than the group-by columns and aggregates in theSELECT
part. In your case, the values of b.* could be random.Are you trying to compute both counts at the same time? If
BookingDate is in
c, then it is easy. If it is in the other table, then it gets messier. _When
JOINing`, please make it clear which columns come from which tables._To get the rest them,