Concept explainers
SQL:
- SQL stands for “Structured Query Language”.
- The current version of SQL is “ANSI SQL – 92”.
- It contains constructs which are used to define and process
database . They are executed using DBMS-supplied command prompt. - SQL is not a
programming language. It is text-based and it is also called as data sublanguage. In order to get SQL as a complete programming language, it should be included in scripting languages like Java, C#, and so on.
Display values from table:
The contents from the table can be viewed by using “SELECT” statement which comes under Data Manipulation Language (DML). Syntax to view the contents using asterisk (*) is as follows:
SELECT * FROM table_Name;
Grouping Rows:
SQL contains “GROUP BY” clause in order to group rows by common data. Though it is very powerful feature, it is hard to understand.
Syntax:
SELECT column_Name1 FROM table_Name GROUP BY column_Name2;
Example: Consider a table “student” contains two columns “student_Name” and “Department”. “GROUP BY” clause is used when there is a need to get the number of students from each department.
The query for this scenario is given as follows.
SELECT department, COUNT (department) FROM student GROUP BY department;
When the above query is executed, number of students from each department will be displayed.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Database Concepts (8th Edition)
- Write an SQL statement to group the data by PetBreed and display the average weight per breed.arrow_forwardBased on the table provided, write the following statements in sql queries.arrow_forwardWrite an SQL statement to display the last name, first name, and email of any owners of cats. Use a subqueryarrow_forward
- Write an SQL statement to display the minimum, maximum, and average weight of dogs.arrow_forwardWrite an SQL statement to add a CHECK constraint to the PET table so that the weight data recorded in the PetWeight column you added to the table in either question 3.47 or 3.49 is less than 250.arrow_forwardBased on the ERD below, write the SQL statement to display the average hourly job charge for a job.arrow_forward
- Write an SQL statement to display the PetBreed column of PET. Do not show duplicates.arrow_forwardWrite SQL statements to the following queries. Retrieve the PRODUCT_NAME that product UNIT_PRICE less than the 10 (use subquery).arrow_forwardCreate a SQL statement to Display the number of clients for each CType with having less than 2 clients in the CLIENTS table.arrow_forward
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage LearningA Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology Ptr