Question

Write a sql query that returns Which states have more than one customer? List the states and the ...

write a sql query that returns Which states have more than one customer? List the states and the number of customers for those states. The list must not include the states that do not have more than one customer.

CUSTOMER_T

CustomerName, Street, City, State, Zip,

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SELECT State, COUNT(State) as no_customers
FROM CUSTOMER_T
group by State having count(State) > 1;

We will use group by a statement to group the customers by the state which they are living in. After grouping using having clause, we will check whether the count of state (Which are grouped) is more than 1 or not. If it's more than one we will print that state and the number of customers as Count(state). From the table, we know that each row belongs to one unique customer

.​

Customer Name Peter Stark Chris Hemsworth Flash Street City Munich London State Germany UK Spain spain Germany UK Spain Gotha

Add a comment
Know the answer?
Add Answer to:
Write a sql query that returns Which states have more than one customer? List the states and the ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT