Posts

Showing posts from 2015

SQL Functions

ISNULL( column_name, value ) - function is used to specify how we want to treat NULL values. e.g. ISNULL(Quantity, 0)) AVG(column_name)  - function returns the average value of a numeric column. COUNT(column_name) - function returns the number of rows that matches a specified criteria. COUNT(DISTINCT column_name) - function returns the number of distinct values of the specified column. FIRST(column_name) - function returns the first value of the selected column. LAST(column_name) - function returns the last value of the selected column. MAX(column_name) - function returns the largest value of the selected column. MIN(column_name) - function returns the smallest value of the selected column. SUM(column_name) - function returns the total sum of a numeric column. UCASE( column_name ) - function converts the value of a field to uppercase. LCASE( column_name ) - function converts the value of a field to lowercase. LEN( column_name ) - func...

SQL JOINS

JOIN clause is used to combine rows from two or more tables based on a common field. INNER JOIN : returns all rows from both tables as long as there is a match between the columns in both tables. All the rows that did not match in the criteria in both the tables will not be returned. SELECT * FROM Orders AS O INNER JOIN Customers AS C ON O.CustomerID = C.CustomerID LEFT JOIN : returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match. SELECT * FROM Customers AS C LEFT JOIN Orders AS O ON C.CustomerID = O.CustomerID RIGHT JOIN : returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match. SELECT * FROM Orders AS O RIGHT JOIN Customers AS C ON O.CustomerID = C.CustomerID FULL JOIN : returns all rows from the left table (table1) and from the right table (table2). SELECT *...

Operators in WHERE clause

The operators that we can use in the WHERE clause are as follows: = Equal <> or != Not equal > Greater than < Less than >= Greater than or equal <= Less than or equal BETWEEN Between an inclusive range LIKE Search for a pattern IN To specify multiple possible values for a column AND The AND operator displays a record if both the first condition AND the second condition are true OR The OR operator displays a record if either the first condition OR the second condition is true

SQL wildcard characters in LIKE

The various types of wildcard characters that can be used within the LIKE clause are as follows: % -> A substitute for zero or more characters e.g. '%S%' _ - >  A substitute for a single character e.g. 'L_n_on' [chars] ->  Sets and ranges of characters to match e.g. [A-z] or [a,b,c] [!chars] or [^chars] ->  Matches only a character NOT specified within the brackets e.g. [!a,b,c]

SQL IN Statement

The SQL IN clause is used to pass on multiple values to the WHERE clause in the statement. SELECT * FROM Territories WHERE RegionID IN (SELECT RegionID FROM Region)

Difference between Total Float and Free Float

Total Float : The total amount of time that a schedule activity may be delayed from its early start date without delaying the project finish date, or violating a schedule constraint. Free Float : The amount of time that a schedule activity can be delayed without delaying the early start date of any immediately following schedule activities.