question

Mianbaba avatar image
Mianbaba asked

How i will generate a list of Countries with number of individual and company customers

Write a single SQL statement to generate a list of countries with the number of individual customers and company customers. The query should have 3 columns named Country, Individuals and Companies. The column Country includes all the countries from the Customer table. The column Individuals and Companies display the number of individual customers and the number of company customers respectively in each country. A company customer is defined by the existence of a company name in the Customer table. If a country does not have any associated company customers, 0 will be displayed in the column Companies for that particular row. Sort the result of the query by the column Country in accending order. Please Help me fast. I am Stuck here.
sqlqueryhomework
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dave_Green avatar image Dave_Green ♦ commented ·
Can you let us know how far you have gotten - which aspect is it you are stuck with?
1 Like 1 ·

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered
The key words you need to look up to get your homework done are GROUP BY and ORDER BY. If you showed work you had done to make it all work, I'd offer more help, but I'm not writing the T-SQL for you.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.