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 SQL statements to the following queries. Retrieve the PRODUCT_NAME that product UNIT_PRICE less than the 10 (use subquery).arrow_forwardShow the product names for products that have been ordered in quantities equal to or exceeding 120. Use a non-correlated subquery in the SQL statement.arrow_forwardWrite the SQL code that will compute the total number of hours worked and total amount billed by all workers.arrow_forward
- write an sql query that displays the parking space number location as well as the name of the staff member to whom the parking space has been allocatedarrow_forwardWhat SQL statement function is used to generate a column, where the value for the new column is dependant on another column's value for the row of data (i.e SQL IF statement)?arrow_forwardTrue or FalseString comparisons in SQL are case sensitive.arrow_forward
- Determine the results of the below query. Explain how the result was calculated. 72 Q.6.4 73 SELECT Year, SUM(Value) 74 FROM Import 75 WHERE CountryID 3 GROUP BY Year; 76arrow_forwardWrite an SQL statement to change the value of Std. Poodle in BreedName of PET_3 to Poodle, Stdarrow_forwardStudent(StudentID, age)School(SchoolID, city)Write an SQL statement for the following query: For every School, list the ID and number of students with the age less than the average age of all students. Order the results in increasing order according to the SchoolID.arrow_forward
- Use the following table to find the OUTPUT of the following SQL queries: Table Name: Patients MEDICAL NO FIRST_NAME SUR NAME DOB GENDER PHONE FAX BLOOD TYPE WEIGHT SMOKER PCR TEST 1001 Said Alalawi 12-Jun-2001 Male 98877445 22114454 A 68 NO Negative 1002 Othman Mualla 20-Apr-2000 Male 78 VES Positive 1003 Sameera Bader 19-Oct-2005 Female 25541122 52 NO Positive 1004 Fahad Alhinai 24-Feb-2004 Male 91122544 AB 66 YES Negative 1005 Shamsa Alfahdi 15-Sep-2002 Female 35 NO Negative SELECT TO CHAR (DOB, 'Mon-DD-YY') FROM patients WHERE Medical no-1001; Answer: 12-Jun-2001arrow_forwardSQL Database Write PL/SQL or T-SQL procedures to retrieve and output the reservation ID, trip ID, number of persons, and trip price for every reservation whose customer number is stored in I_CUSTOMER_NUMarrow_forwardsql statementarrow_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