Question

Using Microsoft SQL Server

2 2020-05-29 Describe how SQL queries work USE Adventure Works2012 example no 1 USE Adventure Works2012 GO SELECT AVG(TotalDu

0 0
Add a comment Improve this question Transcribed image text
Answer #1

example no 1 USE Adventure Works2012 GO SELECT AVG(TotalDue as AVG_TotalDue FROM [Sales) [SalesOrderHeader)

It specifies the use of database,here the name AdventureWork2012 is used to specify the name of the database on which the following query have to be executed

in above query the average value of the column "TotalDue" is calculated from SalesOrderHeader table in the sales schema and shown with the AVG_TotalDue instead of AVG(TotalDue).

example no 2 SELECT SalesOrderID Order Date, TotalDue st Name AS TerritoryName. SELECT AVG(TotalDue) FROM [Sales). [SalesOrde

The above query shows the SalesOrderID,OrderDate,TotalDue, st.Name as TerritoryName of all the terrritory where CountryRegion code is 'GB and totalDue in terriototy is more than or equal to average of the toalDue in all territory for period of order from 1 June 2004 to 30 June 2012

example no 3 SELECT TOP 3 CustomerID, SUM(TotalDue) as TotalSales FROM [Sales) (SalesOrderHeader) soh GROUP BY CustomerID ORD

Here the query is to show customer ID and total sales of top 3 customers in descending order from SalesOrderHeader table

example no 4 SELECT SalesOrderID Order Date. TotalDue, CustomerID from [Sales] [SalesOrderHeader] soh WHERE Customer1D in SEL

The above query shows order details(SalesOrderID,OrderDate,TotalDue,CustomerID) of the top 3 customers in from SalesOrderHeader table

example no 5 SELECT SalesOrderID Order Date, soh. CustomerID FROM [Sales] [SalesOrder Header] soh INNER JOIN SELECT TOP 3 Cus

The above query shows order details(SalesOrderID,OrderDate,CustomerID) of the top 3 customers order from SalesOrderHeader table.

This query is a equivalent to example 4 in result, the only difference is the example 4 uses where clause whereas in example 5 INNER join is used

Add a comment
Know the answer?
Add Answer to:
Using Microsoft SQL Server 2 2020-05-29 Describe how SQL queries work USE Adventure Works2012 example no...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am using oracle sql developer to create some queries to generated reports and it is...

    I am using oracle sql developer to create some queries to generated reports and it is not working. I am not sure how to use count, group by, and order by. Help me fix my query and explain to me how you did, so can do it next time. Also, I have to convert this query to a stored procedure, so can you help me do it too? Here is my query: SELECT COUNT(GUEST.FIRSTNAME), GUEST.FIRSTNAME, GUEST.LASTNAME, GUEST.GUESTTYPE, RESERVATION.RESERVATIONDATE, GUEST.EMAIL, FROM...

  • You will develop an E-Commerce database used to maintain customers, products and sales information. You are...

    You will develop an E-Commerce database used to maintain customers, products and sales information. You are required to 1) gather and analyze requirements 2) design logical structure of the database 3) create stored procedures to develop the tables and insert the data 4) write SQL statements for data extraction and reporting. Throughout the course of this semester you have analyzed the requirements for an eCommerce database, designed and developed your database. As a class we have gone through the process...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT