In the Real World

Pronounced sequel, SQL was originally developed by IBM researchers in the 1970s. It has become the de facto database manipulation language for many database vendors. For database users, mastering SQL has become a sought-after skill set in the information technology world. Most persons who master the SQL language have no trouble finding well-paid positions.

To provide readability in the sections to come, I use a preferred syntax nomenclature for SQL:

• All SQL commands and reserved language keywords are in uppercase. For example, SELECT, FROM, WHERE, and AND are all Jet SQL commands and reserved keywords.

• Even though Microsoft Access is not a case-sensitive application, table and column names used in SQL statements use the same case as defined in the database. For example, a column defined as EmployeeId is spelled EmployeeId in the SQL query.

• Table and column names that contain spaces must be enclosed in brackets. For example, the column name Customer Number must be contained in SQL as [Customer Number]. Failure to do so causes errors or undesired results when executing your queries.

• A query can be written on a single line. For readability, I break SQL statements into logical blocks on multiple lines. For example, look at this SQL statement:

SELECT [Order Details].OrderID, Sum(CCur([UnitPrice]*[Quantity]*(1-[Discount])/ 100)*100) AS Subtotal FROM [Order Details] GROUP BY [Order Details].OrderID;

It should look like this:

SELECT [Order Details].OrderID,

SUM (CCur([UnitPrice]*[Quantity]*(1-[Discount])/100)*100)

AS Subtotal

FROM [Order Details]

GROUP BY [Order Details].OrderID;

0 0

Post a comment