Blog

SQL LCASE() Function
SQL LCASE() Function The LCASE() Function The LCASE() function converts the value of a field to lowercase. SQL LCASE() Syntax SELECT LCASE(column_name) FROM table_name Syntax for SQL Server SELECT LOWER(column_name) FROM table_name SQL LCASE() Example We have the follow…[ More ]
SQL UCASE() Function
SQL UCASE() Function The UCASE() Function The UCASE() function converts the value of a field to uppercase. SQL UCASE() Syntax SELECT UCASE(column_name) FROM table_name Syntax for SQL Server SELECT UPPER(column_name) FROM table_name SQL UCASE() Example We have the follow…[ More ]
SQL HAVING Clause
SQL HAVING Clause The HAVING Clause The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions. SQL HAVING Syntax SELECT column_name, aggregate_function(column_name)FROM table_nameWHERE column_name operator valueGROUP BY column_nameHAV…[ More ]
SQL GROUP BY Statement
SQL GROUP BY Statement Aggregate functions often need an added GROUP BY statement. 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 Syntax SELECT column_name, aggregat…[ More ]
SQL SUM() Function
SQL SUM() Function The SUM() Function The SUM() function returns the total sum of a numeric column. SQL SUM() Syntax SELECT SUM(column_name) FROM table_name SQL SUM() Example We have the following "Orders" table: O_Id OrderDate OrderPrice Customer 1 2008/11/12 10…[ More ]
SQL MIN() Function
SQL MIN() Function The MIN() Function The MIN() function returns the smallest value of the selected column. SQL MIN() Syntax SELECT MIN(column_name) FROM table_name SQL MIN() Example We have the following "Orders" table: O_Id OrderDate OrderPrice Customer 1 2008/1…[ More ]
SQL MAX() Function
SQL MAX() Function The MAX() Function The MAX() function returns the largest value of the selected column. SQL MAX() Syntax SELECT MAX(column_name) FROM table_name SQL MAX() Example We have the following "Orders" table: O_Id OrderDate OrderPrice Customer 1 2008/11…[ More ]
SQL LAST() Function
SQL LAST() Function The LAST() Function The LAST() function returns the last value of the selected column. SQL LAST() Syntax SELECT LAST(column_name) FROM table_name SQL LAST() Example We have the following "Orders" table: O_Id OrderDate OrderPrice Customer 1 2008…[ More ]
SQL FIRST() Function
SQL FIRST() Function The FIRST() Function The FIRST() function returns the first value of the selected column. SQL FIRST() Syntax SELECT FIRST(column_name) FROM table_name SQL FIRST() Example We have the following "Orders" table: O_Id OrderDate OrderPrice Customer …[ More ]
SQL COUNT() Function
SQL COUNT() Function The COUNT() function returns the number of rows that matches a specified criteria. SQL COUNT(column_name) Syntax The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column: SELECT COUNT(column_na…[ More ]
SQL AVG() Function
SQL AVG() Function The AVG() Function The AVG() function returns the average value of a numeric column. SQL AVG() Syntax SELECT AVG(column_name) FROM table_name SQL AVG() Example We have the following "Orders" table: O_Id OrderDate OrderPrice Customer 1 2008/11/12…[ More ]
SQL Functions
SQL Functions SQL has many built-in functions for performing calculations on data. SQL Aggregate Functions SQL aggregate functions return a single value, calculated from values in a column. Useful aggregate functions: AVG() - Returns the average value COUNT() - Returns the numbe…[ More ]
SQL Data Types
SQL Data Types Data types and ranges for Microsoft Access, MySQL and SQL Server. Microsoft Access Data Types Data type Description Storage Text Use for text or combinations of text and numbers. 255 characters maximum Memo Memo is used for larger amounts of text. St…[ More ]
SQL NULL Functions
SQL NULL Functions SQL ISNULL(), NVL(), IFNULL() and COALESCE() Functions Look at the following "Products" table: P_Id ProductName UnitPrice UnitsInStock UnitsOnOrder 1 Jarlsberg 10.45 16 15 2 Mascarpone 32.56 23   3 Gorgonzola 15.67 9 20 Suppose that the "Un…[ More ]
SQL NULL Values
SQL NULL Values NULL values represent missing unknown data. By default, a table column can hold NULL values. This chapter will explain the IS NULL and IS NOT NULL operators. SQL NULL Values If a column in a table is optional, we can insert a new record or update an existing record…[ More ]
SQL Date Functions
SQL Date Functions SQL Dates The most difficult part when working with dates is to be sure that the format of the date you are trying to insert, matches the format of the date column in the database. As long as your data contains only the date portion, your queries will work as expec…[ More ]
SQL Views
SQL Views A view is a virtual table. This chapter shows how to create, update, and delete a view. 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 vie…[ More ]
SQL Views
SQL Views A view is a virtual table. This chapter shows how to create, update, and delete a view. 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 vie…[ More ]
SQL AUTO INCREMENT Field
SQL AUTO INCREMENT Field Auto-increment allows a unique number to be generated when a new record is inserted into a table. AUTO INCREMENT a Field Very often we would like the value of the primary key field to be created automatically every time a new record is inserted. We would li…[ More ]
SQL ALTER TABLE Statement
SQL ALTER TABLE Statement The ALTER TABLE Statement The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. SQL ALTER TABLE Syntax To add a column in a table, use the following syntax: ALTER TABLE table_nameADD column_name datatype To delete a co…[ More ]