Create a view named customer_mobile_details which has the following attributes. Display customer id,customer name,mobile number, sales id, net amount,model name and manufacturer name of the mobiles, they have purchased. Sort the records based on customer id,customer name,sales id in ascending order.
Answers
Answer:
The issue is actually in the question as the mobile number to be taken is the attribute named "Mobile" from the table .
hope it help you...
Answer:
The following SQL query creates a view named customer_mobile_details which has the following attributes. Display customer id, customer name, mobile number, sales id, net amount, model name, and manufacturer name of the mobiles, they have purchased and sorted the records based on customer id, customer name, and sales id in ascending order.
CREATE VIEW customer_mobile_details AS
SELECT customer id, customer name, mobile number, sales id, net amount, model name, manufacturer name FROM customer
Explanation:
For creating a view in SQL, we use CREATE VIEW command with the SELECT command.
Syntax:
CREATE VIEW view_name AS
SELECT col1, col2, col3, --------- colN FROM table_name
However, sorting the data in either ascending or descending order is not possible in the case of SQL view.
The reason behind this is SQL restriction. SQL Server doesn't allow to use of the SORT BY clause for sorting the view. You have to explicitly sort the data first before creating a view for it.
You can use the TOP function for specifying how many rows of data you want to display but those rows can't be sorted.
#SPJ3