Features of Advance SQL Assignment Help
The Advance word in the Advance SQL is added because the Advance SQL have many additional features. And many of the features are discussed below.
- SQL TOP: SQL TOP is similar to SQL Limit which is used to retrieve the subset of record.
Syntax:
{` SELECT TOP [TOP argument] "column_name"
FROM "table_name"; `}Where [TOP argument] means one of them:
- [N]: The first N record are return.
- [M] PERCENT: the records which corresponds the record M% then all qualifying records are return.
- [N]: The first N record are return.
{` SELECT TOP 2 prod_id, prod_sales,date FROM product_information ORDER BY prod_sales DESC ; `}
- SQL Subquery: By the use of SQL subquery we can combine two query with WHERE or HAVING clause.
Syntax:
{` SELECT "column_name1" FROM "table_name1" WHERE "column_name2" [Comparison Operator] (SELECT "column_name3" FROM "table_name2" WHERE "condition"); `}
The Comparison Operator which are used are =,>, <,>=, <=.we can also use text operator such as LIKE.
Example: Two tables product_detail and product_information having a common field i.e. prod_id and two different fields
SQL_Advance:SQL Subquery
- SQL EXISTS:SQL EXISTS is used to check the existence of the inner query then it proceed for the outer query. And if not, the outer query does not execute, and the entire SQL statement returns nothing.
Syntax:
{` SELECT "column_name1" FROM "table_name1" WHERE EXISTS(SELECT * FROM "table_name2" WHERE "condition"); `}
Example: Two tables customer and score having a common field i.e. cust_id
SQL_Advance:SQL Exist
- SQL CASE:It is used as if-then-else type of logic in SQL.
To use SQL-CASE we have two way:
- First way is a simple case expression, in this we compare an expression to static values.
- Second one is a searched CASE expression, where we compare an expression to one or more logical condition.
{` SELECT CASE ("column_name") WHEN "value1" THEN "result1" WHEN "value2" THEN "result2" ... [ELSE "resultN"] END FROM "table_name"; `}
Example: There is one table (product_information) with three fields i.e. prod_id,prod_sales,date in the prod_sales we have applied cases condition - First way is a simple case expression, in this we compare an expression to static values.
SQL_Advance:SQL CASE
To submit Advanced SQL assignment click here