From the following table, create a view named norders that provides a summary of the average and total purchase amounts for each salesman. The view should include the salesman's name along with the rounded average and total purchase amounts.Sample Table: salesmanSample Table: orders
Question
From the following table, create a view named norders that provides a summary of the average and total purchase amounts for each salesman. The view should include the salesman's name along with the rounded average and total purchase amounts.Sample Table: salesmanSample Table: orders
Solution
I'm sorry, but you didn't provide a specific question or the structure of the tables. However, I can provide a general SQL query that might help you.
Assuming you have two tables: 'salesman' with a column 'name' and 'orders' with columns 'salesman_name' and 'purchase_amount', you can create a view named 'norders' as follows:
CREATE VIEW norders AS
SELECT s.name, ROUND(AVG(o.purchase_amount), 2) AS average_purchase, SUM(o.purchase_amount) AS total_purchase
FROM salesman s
JOIN orders o ON s.name = o.salesman_name
GROUP BY s.name;
This SQL statement creates a new view 'norders'. It selects the name from the 'salesman' table and calculates the average and total purchase amounts from the 'orders' table for each salesman. The 'ROUND' function is used to round the average purchase amount to 2 decimal places. The 'JOIN' clause is used to combine rows from both tables based on the salesman's name. The 'GROUP BY' clause is used to group the result-set by one or more columns, in this case, the salesman's name.
Please replace the table and column names with your actual table and column names.
Similar Questions
Create a view named purchase_amount_view to calculate the total purchase amount for each order from the provided table orderdetails.Table Details:Table name: orderdetails (table names are case sensitive)Column Names:order_number (int) - primary keyproduct_code (int) - primary keyquantity_ordered (int)price_each (decimal(8,2))
You are tasked with maintaining a record of daily purchases made by customers. To accomplish this, you need to create a view named daily_purchase_summary. This view will provide a summary of the daily purchases, including the total number of orders placed and the total purchase amount for each day. The purchase amount should be rounded to two decimal places for accuracy.
Write a query to retrieve the names of customers who have made multiple purchases and the count of their purchases.Table: OrdersNote: Tables and values are prepopulated.Alias Name: NumberofProducts
From the following table, create a view named salesown to display the details of salesmen, including their ID, name, and city.Sample table: salesmanNote: Table name and column names are case sensitive.Input format :The input records are already prepopulated as per the given requirement.Output format :The output is a view named salesown that provides the details of salesmen, including their ID (salesman_id), name (name), and city (city) as shown below.
From the following table, create a view 'newyorkstaff' to display details of salesmen who are based in New York.Sample table: salesman
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.