Question

Using SQL: Create a simple query that groups information by a specific column. Explain each step.

Using SQL:

Create a simple query that groups information by a specific column. Explain each step.

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

The SQL query that groups information by a specific column is GROUP BY.

Consider the following table EMPLOYEE.

The SQL query to select name and sum of salary grouped by the column name is

SELECT NAME,SUM(SALARY) FROM EMPLOYEE GROUP BY NAME;

The result is

Thus query returned the names and sum of salaries of employees having same name.

Here the name Ashish is having two rows and the sum of his salary is 3000

GROUP BY Syntax SELECT column_name (s) FROM table_name WHERE condition GROUP BY column_name(s) ORDER BY column_name (s);

Add a comment
Know the answer?
Add Answer to:
Using SQL: Create a simple query that groups information by a specific column. Explain each step.
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
  • Create sql query command for the following. Modify your query and produce the following results. Customer...

    Create sql query command for the following. Modify your query and produce the following results. Customer #000000001 1 1428873.61 9 Customer #000000002 2 1156504.92 10 Customer #000000004 4 4134567.39 31 Customer#000000005 5 1084042.74 9 Customer #000000007 7 3922020.98 24 Column 1 is the customer Name, Column 2, is the customer key, column 3 is the total of the customer orders ($$) and column 4 is the number of orders.

  • I need to write an SQL statement to run this query: SALES has the following column...

    I need to write an SQL statement to run this query: SALES has the following column names: vendorid, name, upc, move, price, qty, year, store the table name is SALES... the sales is not a column in the SALES so it needs to be created in the query with the formula as well. QUESTION BELOW: Query 4: Return the vendor id, vendor name, product UPC code, move, and sales (price * move/qty) for each product sold by store 100 in...

  • For each question, write a SQL query and save it as a "sql" file using a...

    For each question, write a SQL query and save it as a "sql" file using a different query 2, etc. Please execute these queries sequentially name, for example, query1.query product id (PK) category brand production_cost (Not Null) (FK) name (Not Null) Toothpaste Supermarket 1 Multivitami Supermarket 2 Shampoo acket T-shirt Supplements Supermarket Department4 Department5 Pharmacy Pharmacy 6 6 10 Query1. Update the Product table by adding another column as shown above ucts (name) with uery2. Retrieve all the uction cost...

  • For this hands-on project, you will use the SQL Server named instance SQLSERVERHOA, and the HandsOnOne...

    For this hands-on project, you will use the SQL Server named instance SQLSERVERHOA, and the HandsOnOne database and tables you created in previous chapters. The objective of this activity is to practice generating keys and encrypting/decrypting data. Document each step by taking a screen shot of the Query Editor window after successfully executing each SQL query. 1.In SQL Server Management Studio, open a new Query Editor window, which you will use for completing all steps in this activity. 2.Create a...

  • I am using Oracle SQL Live so please write the SQL Query in the format that...

    I am using Oracle SQL Live so please write the SQL Query in the format that Oracle SQL Live can run I need to create a trigger that will update the Product QoH when a new product is purchased. (A new product is purchased when a row is added to the line table). I have linked the code of the script since it exceed Chegg’s Character Limit: https://docs.google.com/document/d/1HbHnMrk6Qw99B72kpDyYCFibUJVsYEi-6RKDsmb3fg4/edit?usp=sharing

  • Create SQL for the following: Construct a query to show customers with an annual income greater...

    Create SQL for the following: Construct a query to show customers with an annual income greater than $100,000 who have a credit rating of “Fair,” “Poor,” “Very Poor,” or “Extremely Poor.” Show each customer’s first name, last name, credit description, and annual income.

  • (SQL Coding) Create a simple view called view_d_songs_77 that contains the ID, title and artist from...

    (SQL Coding) Create a simple view called view_d_songs_77 that contains the ID, title and artist from the DJs on Demand table for each “New Age” type code. In the subquery, use the alias “Song Title” for the title column

  • SQL query: Write a SQL statement using the employees table and retrieve employees whose monthly salary...

    SQL query: Write a SQL statement using the employees table and retrieve employees whose monthly salary (including their commission) is greater or equal to 5,000 but less than or equal to 17,000 (we are assuming the salary on the table is monthly). In other words, if their monthly salary was 1000 and their commission was .2, their total monthly salary would be 1200 and given the criteria above this instance would not be selected. Please display the full name of...

  • Please write SQL Query for following questions using Northwind Database: 1. Create a procedure to add...

    Please write SQL Query for following questions using Northwind Database: 1. Create a procedure to add a new record to Territories table. Call it NewTerr. Add the following records using the procedure. TerritoryID        TerritoryDescription     Region 88888 Brooklyn 1 99999 Waco 4 77777 Long Beach 2 2. Create an Update Procedure that will change the Region from 1 to 3 for record with TerritoryID 88888. Call it Update88. 3. Create a Delete Procedure that will delete the one record from...

  • Create the database and tables for the database. Show all SQL statements. Include primary and foreign...

    Create the database and tables for the database. Show all SQL statements. Include primary and foreign keys. Insert data into each table. Show select statements and display the output of each table. Note:Student’s name must be inserted into table as part of the data! Perform the SQL below: Query one table and use WHERE to filter the results. The SELECT clause should have a column list, not an asterisk (*). State the purpose of the query; show the query and...

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