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

  Equilibrium rate of return on assets-equation of yield

In an economy where the equilibrium rate of return on assets is 5 per cent per year, suppose there are three assets A, B and M. A is an acre of land and has an annual cash flow of $50 (received at the end of the year) and is not expected to appreciat..

  The recession experienced by economy will cause short run

If left alone, the recession experienced by an economy will cause the short-run:

  Decrease the number of substitutes for some types of labor

We’ve seen that monopolistically competitive firms will try to differentiate their products in order to eliminate substitutes. Are there comparable measures that can be taken in labor markets to decrease the number of “substitutes” for some types of ..

  Movement along versus shift of demand and supply curves

Which of the following would cause a movement along the supply curve Ithat it is a change in the quantity supplied) for peanut butter? Check all that apply. Which of the following would cause a shift of the supply curve for peanut butter? Check all t..

  The lifecycle hypothesis

Suppose that medical researchers discover a new drug which slows the aging process allowing the average life span in the United States to increase to 95 years of age. The lifecycle hypothesis suggests that

  Improvement in production technology for a specific good

An improvement in production technology for a specific good will cause a(n):

  Explicidate a profit-maximizing bundle will not exist

Explicidate that a profit-maximizing bundle will typically not exist for a technology that exhibits increasing returns to scale as long as there is some point that yields a positive profit.

  Product innovation charter

Referring to text Chap 3 “ Product Innovation Charter”, explain what are the benefits of this up front charter document early on during the product development process ?? Also, explain your personal experience of the benefits you experienced from dev..

  The generalized demand and supply functions for good

The generalized demand and supply functions for good X are Qxd = 100 – 2PX + 0.01M + 8 PY - 4Pz Qxs = 50 + 3PX – 6PI + PT Where Qxd = quantity demanded of good X Px = price of good X M = consumer income PY = price of good Y Pz= price of good Z Qxs = ..

  Explain how does the empirical rule

Explain how does the empirical rule help to explain the ways in which values in a set of numerical data cluster and distribute.

  Identify contributions of components of per capita growth

Consider the Cobb-Douglas production function . a. Write this in growth-rate terms. b. Next, define this in terms of per capita growth and identify the contributions of the components of per capita growth. c. If the growth rate of capital per worker ..

  Indicated level of introvertedness and extrovertedness

A sales manager examined age data, education level, a personality factor that indicated level of introvertedness/extrovertedness, and level of sales attained by the company's 120-person salesforce. The technique used was regression analysis.

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