Reference no: EM131439419
Write a query to show country wise number of customers and number of orders: Run the query: SELECT count(a.customerid), count(b.orderid),a.country from Customers a inner join Orders b on a.customerid = b.customerid group by a.country
Observe the results. You will find number of orders for each country to be correct. But number of customers in each country is not correct. For example, query returns 13 as counts for both customers and orders in the country Argentina. This is because one customer can have multiple orders and each with order the customer count is also being increased.
To avoid this problem, you can use DISTINCT as below:
SELECT count(DISTINCT a.customerid), count(b.orderid),a.country from Customers a inner join Orders b on a.customerid = b.customerid group by a.country
Observer the results. The above query counts each customer only once.
If customers from a country has no orders yet, above query will not show that country. In such cases if you want to display number of customers from that country and a null value for number of orders, you should replace INNER JOIN with LEFT JOIN. However W3SCHOOLS does not support LEFT JOINS yet.
Policy described
: Assume Bill owns the ISO Ho 2 policy described in this chapter. The limits are as follows: A= $120,000 B=$12,000 C=$60,000 D=$24.000 E=$100,000 F= $5,000 The replacement cost of Bill's home is $130,000, the contents are Valued at $70,000, and depreci..
|
Discussing some causes of aggressive behaviors
: Provide some insight into Couple violence by discussing some causes of aggressive behaviors and by the role that culture plays in violence in relationships.
|
Provide a justified and academically defended argument
: Compose a one-page essay in which you will take a first-person perspective of the situation, describe the debate in your own words, and provide a justified and academically defended argument for one side or the other. The essay will need to reflec..
|
Develop a spreadsheet model to find intercept and slope
: Thomas wants to predict the sales figures of his company for the upcoming year. On the basis of historical data, he concludes that a linear function passes through the observed data points for the first and sixth years.
|
Number of customers and number of orders
: Write a query to show country wise number of customers and number of orders: Run the query: SELECT count(a.customerid), count(b.orderid),a.country from Customers a inner join Orders b on a.customerid = b.customerid group by a.country
|
Locate and evaluate a periodical or newspaper article
: Locate and evaluate a periodical or newspaper article in print or online (e.g,, Wall Street Journal, New York Times, Time magazine, The Economist, Forbes) that details an economic issue on the local, state, or federal level. Make sure that the art..
|
Develop an e-r diagram for lms
: Develop an E-R diagram for LMS that includes at least six major entities with relationships tied between them. Consider cardinality or modality and include relationships that are potentially many-to-many, one-to-one, and one-to-many and explain wh..
|
Difference between data and entity models
: Can you explain the difference between data and entity models, data flow diagrams and process models?
|
Determine the descriptive and explanatory methods
: Determine the descriptive, explanatory, and predictive analytical methods used by Cox Committee, IC, and CRS to develop the report's conclusions on the PRC's intelligence threat. Your assignment is to describe the various analytical methods used...
|