SQL Server

The GROUP BY Statement

The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.SQL GROUP BY SyntaxSELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name; SQL GROUP BY ExampleNow we want to...

The SQL DELETE Statement

The DELETE statement is used to delete rows in a table.SQL DELETE Syntax DELETE FROM table_name WHERE some_column=some_value; SQL DELETE ExampleAssume we wish to delete the customer "Alfreds Futterkiste" from the  "Customers" table.We use the following SQL statement:Example DELETE FROM...

The SQL UPDATE Statement

The UPDATE statement is used to update existing records in a table.SQL UPDATE Syntax UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value;SQL UPDATE ExampleAssume we wish to update the customer "Alfreds Futterkiste" with a new  contact person and city.We use the...

The SQL INSERT INTO Statement

The INSERT INTO statement is used to insert new records in a table.SQL INSERT INTO SyntaxIt is possible to write the INSERT INTO statement in two forms. The first form does not specify the column names where the data will be inserted, only their values:INSERT INTO table_name VALUES...

The SQL LIKE Operator

The LIKE operator is used to search for a specified pattern in a column.SQL LIKE Syntax SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern;SQL LIKE Operator ExamplesThe following SQL statement selects all customers with a City starting with  the letter "s":Example SELECT *...

The IN Operator

The IN operator allows you to specify multiple values in a WHERE clause.SQL IN Syntax SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...);

The SQL BETWEEN Operator

The BETWEEN operator selects values within a range. The values can be numbers, text, or dates.SQL BETWEEN SyntaxSELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;

The SQL SELECT INTO Statement

The SELECT INTO statement selects data from one table and inserts it into a  new table. SQL SELECT INTO SyntaxWe can copy all columns into the new table:SELECT * INTO newtable [IN externaldb] FROM table1;Or we can copy only the columns we want into the new table:SELECT column_name(s) INTO...

SQL CREATE VIEW Statement

In SQL, a view is a virtual table based on the result-set of an SQL statement.A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.You can add SQL functions, WHERE, and JOIN statements to a view and present the data...

The SQL UNION Operator

The UNION operator is used to combine the result-set of two or more SELECT  statements.Notice that each SELECT statement within the UNION must have the same number  of columns. The columns must also have similar data types. Also, the columns in  each SELECT statement must be in the...

1 | 2 | 3 >>