Question

Write an update statement modifies the sales_total column of sales_totals table. Modify the sales_total as "2345.56"...

Write an update statement modifies the sales_total column of sales_totals table.

Modify the sales_total as "2345.56" for the representative with id 4 for the year 2017

After execution of your query, data of sales_Totals table should look as shown below :

rep_id sales_year sales_total

1 2016 1274856.38

1 2017 923746.85

1 2018 998337.46

2 2016 978465.99

2 2017 974853.81

2 2018 887695.75

3 2016 1032875.48

3 2017 1132744.56

4 2017 2345.56

4 2018 72443.37

5 2017 422847.86

5 2018 45182.44

2. Consider the modified “sales Total “table from 5th question to solve this query.

Write SELECT statement using subquery that returns these columns from sales_totals table

“Representative ID” : rep_id column

“Year of sales” : sales_year column

“Total sales”: sales_total column

Return only the rows that have lowest sales_total.

Homework Answers

Answer #1

1) Modify the sales_total as "2345.56" for the representative with id 4 for the year 2017

ans == we used here rep_id and Sales_year as conditon to update the row value of sale_total

query==

UPDATE sales_totals
SET sales_total = '2345.56' WHERE rep_id =4 AND sales_year=2017;

2)

Write SELECT statement using subquery that returns these columns from sales_totals table

“Representative ID” : rep_id column

“Year of sales” : sales_year column

“Total sales”: sales_total column

Return only the rows that have lowest sales_total.

ans== We used Min function on sale total in subquery which returns Minimum sale total and then compared with query.

Query==

SELECT rep_id AS "Reprensentative ID",sales_year AS "Year of sales",sales_total AS "Sale Totals" FROM `sales_totals` WHERE sales_total = (SELECT MIN(sales_total) FROM sales_totals);

Know the answer?
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
Similar Questions
Write an UPDATE statement that modifies the Invoices table. Change the terms_id column to 2 for...
Write an UPDATE statement that modifies the Invoices table. Change the terms_id column to 2 for each invoice that's for a vendor with a default_terms_id of 2.
Write SELECT statement that returns the "Representative ID" and their highest sales total of that sales...
Write SELECT statement that returns the "Representative ID" and their highest sales total of that sales representative, grouped by the " Representative ID" . Representative ID    : rep_id column of rep_totals table "Highest sales of Representative " : maximum sales_total of that representative. Return only the rep_id whose highest sales_total is greater than 900000 Expected Output: Representative ID Highest sales of representative 1 1274856.38 2 978465.99 3 1132744.56
1.Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name"...
1.Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name" column with the rep_first_name column , a comma, a space and the rep_last name. Return only the sales representatives whose last name starts with "Mar" 2. Write a SELECT statement that  joins the sales_rep table to the sales_totals table using JOIN clause and returns these columns : "Representative Last name" : rep_last_name from sales_rep table " Year of sales " : sales_year column of sales_totals...
Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name"...
Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name" column with the rep_first_name column , a comma, a space and the rep_last name. Return only the sales representatives whose last name starts with "Mar" Write a SELECT statement that joins the sales_rep table to the sales_totals table using JOIN clause and returns these columns : "Representative Last name" : rep_last_name from sales_rep table " Year of sales " : sales_year column of sales_totals...
Write a SQL statement which joins the parts table with the supplier table and lists the...
Write a SQL statement which joins the parts table with the supplier table and lists the part_name, supplier_name for all parts in the part table. The supplier_id column in the suppliers table is the primary key in the suppliers table, and this key has been exported to the parts table where it is a foreign key. You should use an inner join for this query. Write a SQL statement which joins the parts table with the suppliers table and lists...
Write a SELECT statement that returns one row for each general ledger account number that contains...
Write a SELECT statement that returns one row for each general ledger account number that contains three columns: The account_description column from the General_Ledger_Accounts table The count of the items in the Invoice_Line_Items table that have the same account_number. The sum of the line_item_amount columns in the Invoice_Line_Items table that have the same account_number Return only those rows where the count of line items is greater than 1. This should return 10 rows. Group the result set by the account_description...
1. Write a SELECT statement to count SKUs for each department, i.e., a table of two...
1. Write a SELECT statement to count SKUs for each department, i.e., a table of two columns, departments and their SKU counts. use cape_codd; select department, count(*) from sku_data group by department ; 2. List buyers who is responsible for at least two SKUs, in three columns, department, buyer, sku count. Sort buyers by their department names in ascending order. select department, buyer, count(sku) from sku_data group by buyer ; 3. Write a SQL statement which returns all the orders....
All these to be done in MATLAB: 1.1)Define a column vector, called “b” in MATLAB that...
All these to be done in MATLAB: 1.1)Define a column vector, called “b” in MATLAB that stored floating point numbers between 0.6 to 2.5 in increment of 0.2. 1.2)What is the size of vector b? How is the size of ‘b’ stored? Define number of rows of ‘b’ in variable ’row’ and number of columns of “b” in variable “col”. 1.3)Define matrix “A” as a 10 by 10 matrix of all “1”s. 1.4)Update matrix “A” as following: set all the...
In SQL working with data types 1. Write a SELECT statement that returns these columns from...
In SQL working with data types 1. Write a SELECT statement that returns these columns from the Instructors table: a. The monthly salary (the AnnualSalary column divided by 12) b. A column that uses the CAST function to return the monthly salary with 1 digit to the right of the decimal point c. A column that uses the CONVERT function to return the monthly salary as an integer d. A column that uses the CAST function to return the monthly...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL CPTR HIST MATH RELB Data Type Text Text Text Text Text Number Currency Date/Time Text DEPT_TITLE Biology Computer Science History Mathematics Religion    Field Name DEPT_CODE DEPT_TITLE Data Type Text Text INSTRUCTIONS Use SQL commands to create the tables and enter the data shown above using MS Access. Write the following SQL statement given below: 1. 2. 3. 4. 5. 6. 7. 8. 9....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT