Number of customers and number of orders

Assignment Help Business Economics
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.

Reference no: EM131439419

Questions Cloud

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...

Reviews

Write a Review

Business Economics Questions & Answers

  Economics assignment

This document contains various important questions and their appropriate answers in the subject field of Economics.

  Demand and supply curves

Economics is the study of the principles governing the allocation of scarce means among competing ends when the objective of the allocation is to maximize the attainment of the ends.

  Long-run perfectly competitive equilibrium for the firm

Evaluate Government intervene and correct this situation?(a) Explain the concept of a concentration ratio. A rise in the price of magarine Explain the impact of external costs and external benefits on resource allocation long-run perfectly c..

  Supply and demand diagrams

Explain each of the following using supply and demand diagrams,  With the use of a graph, explain how these two programs affect cigarette consumption and the price of cigarettes.

  Case study: fisher-price toys

The case study of the Fisher-Price Toys, Inc., a popular case in basic economics and management from the prestigious Harvard Business School.

  Draw the production possibility curve

Draw the production possibility curve and a. Define consumer surplus and producer surplus.

  Tax revenue

The Australian government administers two programs that affect the market for cigarettes

  Maximize total welfare

How many tickets to sell to maximize total welfare.

  Difference between the cv and the ev

The change in consumer surplus (?CS) is not "theoretically" justifiable like the CV and EV but it continues to be the most widely used measure of consumer welfare change. Explain how this can be reconciled

  Depict von neumann-morgenstern utility index u in a diagram

Depict the von Neumann-Morgenstern utility index u in a diagram

  What is the market solution

What is the market solution (market price and quantity) and What is the total surplus of the society under the market solution

  Calculate gross national product and net national product

Calculate gross national product and net national product

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd