Question

In: Computer Science

How to write a query in SQL using the Group by function to decide if the...

How to write a query in SQL using the Group by function to decide if the results of the diet worked. There are 6 columns ID, Gender, treatment, start_weight_kg, end_weight_kg, and correct change (end weight minus start weight).

With the information given write a SQL to determine if the the results(correct change) worked.

Question is not incomplete.

Solutions

Expert Solution

SQL Query :

select * from Diet GROUP BY Gender,Id,Treatment,start_weight_kg,end_weight_kg,correct_changes;

Note: I had taken sample recods into my sql database using above columns and below is the output screenshots


Related Solutions

Describe in words what the function of each line is in the following SQL query The...
Describe in words what the function of each line is in the following SQL query The lyrics database is provided under question 3 for context 1. select studioID, studioname, base from salespeople sa inner join studios st on (sa.salesID = st.salesid) where base < 300 2. SELECT artistName FROM Artists WHERE artistID IN (SELECT artistID FROM Titles) 3. select m.lastname, m.firstname, s.lastname         from members m inner join salespeople s using (salesID)         order by m.lastname asc; The lyrics database...
1. Write a query in SQL to find the full name of the “Actors” who appeared...
1. Write a query in SQL to find the full name of the “Actors” who appeared in the movie titled Star Wars (using JOIN ). 2.Write a SQL query to find the movie Title that has received Lowest rating from reviewers, but whose actors have received an award for their contribution in movie. (Expected Output: Fantastic Beasts and Where to Find Them) 3.Write a SQL query that display the list of genres, Number of movies in that genre grouped by...
In sql: Write a query to produce a listing of unique vendor names who have at...
In sql: Write a query to produce a listing of unique vendor names who have at least one invoice with us. You are using a table view called COMPANY_INFORMATION that lists a vendor id, vendor name, term id, and term description. The second table you will reference is the invoice table that lists vendor id, invoice num, invoice number, and invoice total. Do not show duplicate results.
1. How do indexes improve SQL query performance? 2. How can stored procedure design improve query...
1. How do indexes improve SQL query performance? 2. How can stored procedure design improve query times in a data mart? 3. Why/How does de-normalization of a data mart design improve performance of queries? 4. What is a different between Client-Servervs. Distributed Architecture? 5. What are some primary features of a 3-tier architecture design?
5. Write the SQL query that accomplishes the task in the ZAGI Retail Company Sales Department...
5. Write the SQL query that accomplishes the task in the ZAGI Retail Company Sales Department Database: 5.1.3. Display the CustomerName and CustomerZip for all customers, sort alphabetically by CustomerName. 5.1.4. Display the RegionID of regions where we have stores (use only table STORES and do not display the same information more than once). 5.1.5 Display all the information for all stores whose ReigionID value is C 5.1.8 Display the ProductID, ProductName, ProductPrice, and VendorName for all products. Sort the...
Write a SQL query to find the movie Title that has received Lowest rating from reviewers,...
Write a SQL query to find the movie Title that has received Lowest rating from reviewers, but whose actors have received an award for their contribution in movie. Output: Fantastic Beasts and Where to Find Them            //   THE DATABASE // DROP DATABASE IF EXISTS cs431_movie_database; CREATE DATABASE cs431_movie_database; USE cs431_movie_database; CREATE TABLE `artists` ( `artist_id` INT NOT NULL AUTO_INCREMENT, `first_name` varchar(45) NOT NULL, `last_name` varchar(45) NOT NULL, `contact_no` varchar(15) DEFAULT NULL, `Profession` TEXT DEFAULT NULL, `birth_date` datetime DEFAULT NULL,...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
1.Write an SQL query that retrieves all pairs of suppliers who supply the same product, along...
1.Write an SQL query that retrieves all pairs of suppliers who supply the same product, along with their product purchase price if applicable. 2.Create a view SUPPLIEROVERVIEW that retrieves, for each supplier, the supplier number, the supplier name, and the total amount of quantities ordered. Once created, query this view to retrieve suppliers for whom the total ordered quantity exceeds 30. 3.Write a nested SQL query to retrieve all purchase order numbers of purchase orders that contain either sparkling or...
Create a ‘Student’ table using SQL query. The table must have at least five attributes from...
Create a ‘Student’ table using SQL query. The table must have at least five attributes from your choice with different data types.
Using SQL, write a table-valued function that: -- takes a space delimited string as input (Input...
Using SQL, write a table-valued function that: -- takes a space delimited string as input (Input string will be a sentance ex: "The cat is on the chair and the bear is on the chair") -- returns a table (word varchar(max), count int) (Output is a table that shows how many times each word appeared in the sentance) Where each space-delimited “word” in the string appears in the table along with the number of times it appeared in the input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT