Question

In a table called Sales, there are columns named Quantity and StockID. In another table named...

In a table called Sales, there are columns named Quantity and StockID. In another table named Items there are columns named StockID, which is the connecting column to the other table, ItemID, and ItemName. Write a query that returns the ItemID, ItemName, and the average, min, and max quantities for all stock items. And sort the results by average quantity, DESC

TSQL

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

If you have any doubts, please give me comment...

SELECT ItemID, ItemName, AVG(Quantity) average, MIN(Quantity) minimum, MAX(Quantity) maximum

FROM Sales S, Items I

WHERE S.StockID = I.StockID

GROUP BY ItemID, ItemName

ORDER BY average DESC;

Add a comment
Know the answer?
Add Answer to:
In a table called Sales, there are columns named Quantity and StockID. In another table named...
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
  • For the following question: In a table called AllColors there are columns called Colors and ColorName....

    For the following question: In a table called AllColors there are columns called Colors and ColorName. In another table called Items there are columns called ItemID, ItemName, SupplierID, and the connecting column which Colors. Return the Colors, ColorName, and the count items for each color. And order results by the count, DESC, I have the following answer: SELECT Colors, ColorName, COUNT(*) as cnt FROM AllColors A, Items I WHERE A.Colors = I.Colors GROUP BY Colors, ColorName ORDER BY cnt DESC;...

  • 5. Write a SELECT statement that returns these columns from the Orders table: OrderID OrderDate ShipDate...

    5. Write a SELECT statement that returns these columns from the Orders table: OrderID OrderDate ShipDate Return only the rows where the ShipDate column contains a null value. 6. Write a SELECT statement that returns all columns from the Addresses table State is equal to CA 7. Write a SELECT statement that returns all columns from the Products table Product name has a "ru" in its name 8. Write a SELECT statement that returns these columns from the Customers table...

  • With a single query create a new table named QBITEM containing the ITEMNAME, AND ITEMTYPE of...

    With a single query create a new table named QBITEM containing the ITEMNAME, AND ITEMTYPE of items in the ITEM table that have a color beginning with the letter B (e.g Brown, Black,…….) and COLOR. These columns should be called PRODUCT NAME , PRODUCT TYPE AND PRODUCT COLOR in the new table. Answer PRODUCT NAME PRODUCT TYPE PRODUCT COLOR Map Case E Brown Pocket Knife - Avon E Brown Pocket Knife - Nile E Brown Camel Saddle R Brown Stetson...

  • For this problem, assume salesperson data are stored in a database table named staff. Also assume the columns in the table are named name, carsSold, and totalSales Write a Python function named ge...

    For this problem, assume salesperson data are stored in a database table named staff. Also assume the columns in the table are named name, carsSold, and totalSales Write a Python function named getSalesSortedByNames. Your function will have 2 parameters. The first parameter is a database cursor and the second parameter is a float. Your function should start by retrieving those rows in the staff table whose totalsales field is equal to the second parameter. (The next paragraph shows the Python...

  • #6 Write a SELECT statement that returns these columns: The count of the number of orders...

    #6 Write a SELECT statement that returns these columns: The count of the number of orders in the Orders table The sum of the tax_amount columns in the Orders table Write a SELECT statement that returns one row for each category that has products with these columns: The category_name column from the Categories table The count of the products in the Products table The list price of the most expensive product in the Products table Sort the result set so...

  • Table 1-1 shows example metadata for a set of data items. Identify three other columns for...

    Table 1-1 shows example metadata for a set of data items. Identify three other columns for these data (i.e., three other metadata characteristics for the listed attributes) and complete the entries of the table in Table 1-1 for these 3 additional columns (for example the existing ones are Name, Type, Length, Min, Max, Description; an additional column could be something like “Required Field”). Name Type Length Min Max Description Course Alpha 30 Course ID and Name Section Integer 1 1...

  • write a Java console application that Create a text file called Data.txt. Within the file, use...

    write a Java console application that Create a text file called Data.txt. Within the file, use the first row for the name and data title, and use the second row for column headers. Within the columns, insure that the first column is a label column and other columns contain numeric data. In your application, read file Data.txt into parallel arrays, one for each column in the file. Create method printArrays to print the header row(s) and the (unsorted) data in...

  • Start Access. Open the downloaded Access file named exploring_acap_grader_a1_Loans.accdb. Import the exploring_acap_grader_a1_Clients.xlsx Excel workbook into a...

    Start Access. Open the downloaded Access file named exploring_acap_grader_a1_Loans.accdb. Import the exploring_acap_grader_a1_Clients.xlsx Excel workbook into a table named Clients. While importing the data, make sure to select the option First Row Contains Column Headings, and select ClientID as the primary key field. After you have completed the import, open the Clients table in Design view. Change the ClientID field size to 6 and remove the @ symbol from the ClientID format property. Change the ZIP field size to 5. Change...

  • 2) Write a SELECT statement that returns these columns from the DATE_SAMPLE table int EX database....

    2) Write a SELECT statement that returns these columns from the DATE_SAMPLE table int EX database. The start_date column. A column that uses the DATE_FORMAT function to return the start_date column with its month name abbreviated and its month, day and two-digit year separated by slashes. A column that uses the DATE_FORMAT function to return the start_date column with its month and day returned as integers with no leading zeros, a two-digit year and all date parts separated by slashes....

  • 4a) Create a new table that has one column called GoodID and 2 or 3 other...

    4a) Create a new table that has one column called GoodID and 2 or 3 other columns with whatever names and data types you want. But set up a Primary Key Constraint on the GoodID column. Use DESCRIBE to show the column definitions for your table, and paste that in here: 4b) INSERT one row into the table with GoodID equal to 13 and whatever other data (column values) you want. 4c) INSERT another row into the table with GoodID...

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