SQL Server – Scalar Functions Examples

  ------------------------- -- Scalar Functions ------------------------- ------------------------ -- Numeric Functions ------------------------ -- * Ceiling SELECT productName , unitPrice , unitPrice * 0.3 , CEILING(unitPrice * 0.3) FROM products -- * Floor...

SQL Server – SET Operators Examples

  ------------------------------- -- SET Operators ------------------------------- CREATE TABLE zugi (id int) CREATE TABLE ee_zugi (id int) INSERT INTO zugi VALUES (1) , (2) , (4) , (6) , (8) , (10) INSERT INTO ee_zugi VALUES (1) , (3) , (5) , (7) , (9) , (10)...

SQL Server Group Functions Examples

  ---------------------------- -- Group Functions ---------------------------- ---------------------------- -- AVG ---------------------------- SELECT AVG(unitPrice) FROM products -- Error SELECT AVG(productName) FROM products -- Error SELECT AVG(hireDate) FROM...

SQL Server Where Clause Examples

  -------------------------------- -- Basic WHERE -------------------------------- SELECT productName , unitPrice FROM products WHERE unitPrice > 20 SELECT productName , unitPrice FROM products WHERE productName = 'CHAI' SELECT lastName ,...

SQL Server Basic SELECT Examples

  -- Basic SELECT Statement SELECT * FROM employees -- Choosing specific columns SELECT lastName , firstName , Address FROM employees -- Naming / Coding Conventions SeLEct LAstNAme, firstNAME FROM emplOYEES select lastname , firstname from employees /* comments...

SQL Server CREATE TABLE examples

-- DROP DATABASE testDB CREATE DATABASE testDB GO USE testDB GO -------------------------- -- DDL -------------------------- ------------------------- -- CREATE TABLE EX1 ------------------------- CREATE TABLE employees (employeeID int, lastName varchar(25)) DROP...