SQL Examples

Learn to Code SQL Example – SQL | Case Statement

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | Case Statement Control statements form the heart of most languages since they control the execution of other sets of statements. These are found in SQL too, and should be exploited for uses such as query filtering and query optimization through careful selection of …

Learn to Code SQL Example – SQL | WHERE Clause

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | WHERE Clause WHERE keyword is used for fetching filtered data in a result set. It is used to fetch data according to a particular criteria. WHERE keyword can also be used to filter data by matching patterns.   Basic Syntax: SELECT column1,column2 FROM table_name WHERE …

Learn to Code SQL Example – SQL | INSERT INTO Statement

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | INSERT INTO Statement The INSERT INTO statement of SQL is used to insert a new row in a table. There are two ways of using INSERT INTO statement for inserting rows: Only values: First method is to specify only the value of data to …

Learn to Code SQL Example – SQL | DELETE Statement

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | DELETE Statement The DELETE Statement in SQL is used to delete existing records from a table. We can delete a single record or multiple records depending on the condition we specify in the WHERE clause. Basic Syntax: DELETE FROM table_name WHERE some_condition; table_name: …

Learn to Code SQL Example – SQL | UPDATE Statement

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | UPDATE Statement The UPDATE statement in SQL is used to update the data of an existing table in database. We can update single columns as well as multiple columns using UPDATE statement as per our requirement. Basic Syntax UPDATE table_name SET column1 = …

Learn to Code SQL Example – SQL | SELECT TOP Clause

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | SELECT TOP Clause SELECT TOP clause is used to fetch limited number of rows from a database. This clause is very useful while dealing with large databases. Basic Syntax: SELECT TOP value column1,column2 FROM table_name; value: number of rows to return from top …

Learn to Code SQL Example – SQL | ORDER BY

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | ORDER BY The ORDER BY statement in sql is used to sort the fetched data in either ascending or descending according to one or more columns. By default ORDER BY sorts the data in ascending order. We can use the keyword DESC to sort …

Learn to Code SQL Example – SQL | Aliases

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | Aliases Aliases are the temporary names given to table or column for the purpose of a particular SQL query. It is used when name of column or table is used other than their original names, but the modified name is only temporary. Aliases …

Learn to Code SQL Example – SQL | Intersect and Except clause

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | Intersect & Except clause 1. INTERSECT clause : As the name suggests, the intersect clause is used to provide the result of the intersection of two select statements. This implies the result contains all the rows which are common to both the SELECT statements. …

Learn to Code SQL Example – SQL | Union Clause

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | Union Clause The Union Clause is used to combine two separate select statements and produce the result set as a union of both the select statements. NOTE: The fields to be used in both the select statements must be in same order, same …