x

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.

more ▼

asked May 23, 2015 at 12:44 PM in Default

avatar image

Mianbaba
1 3

Can you let us know how far you have gotten - which aspect is it you are stuck with?

May 24, 2015 at 01:24 PM Dave_Green ♦
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered May 26, 2015 at 10:46 AM

avatar image

Grant Fritchey ♦♦
137k 20 47 81

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1208
x461
x113

asked: May 23, 2015 at 12:44 PM

Seen: 200 times

Last Updated: May 26, 2015 at 10:46 AM

Copyright 2018 Redgate Software. Privacy Policy