Microsoft
Software
Hardware
Network
Question : SQL Query to find number of customers with X bookings
Hello Experts!
I don't know if this is possible, and I've had a look round some SQL sites trying to find some ideas of how to do this, but to no avail. What I'd like to do is this:
I have a table with 8,000 customers in, and another table with 30,000 odd bookings. Each booking has the customer id from the customers table as one of the fields.
What I'd like to do is run a query to find out how many customers have 1 booking, how many have 2 bookings, how many have 3 and so on.
Is there a way to do this? Any pointers for where to look are appreciated (almost) as much as the solutions! ;)
Many thanks,
Dan
Answer : SQL Query to find number of customers with X bookings
select Customer_id, count (bookings.booking_id) as count from customer c
left join bookings b on b.
customer_id = c.
customer_id
group by
customer_id
order by count asc
Random Solutions
Disable / enable custom menu items
Counting the number of cells in a given range that begin with a specific letter.
LSASRV Event Log errors, EventID 40960
How do I retrieve the path and template name of an attached Word template?
SSIS password Recovery or expiration
Intercepting WM_KEYDOWN messages
Formatting a 60gb hard drive fails in Disk Management
Create accdr runtime without msi executable
I have rules that automatically move email into Outlook 2007 sub folders. Only the most important email stays in my Inbox. Need a way of displaying all Unread Mail that is only in my Outlook Inbox
Certification renewal for OWA