Archive of SQL examples
SQL simple SQL advanced TSQL Spatial SQL Python Links
Welcome to my archive of SQL examples.

SQL (Structured Query Language) is a widely used language for quering relational databases. The code in this archive deals with real life tasks like generating sales statistics, calculating next birthday of employee and so on, using Transact-SQL, MySQL and Jet-SQL syntax. One section of the archive is devoted to Simple SQL Queries sutable for beginners, others are adressing specific issues including procedures syntax, functions, Spatial Queries and client scripting like ASP. Some of the scripts reference the "Colombo Ltd" database. This is a sample database with some business data in it. As for the standards, most of the features discussed are part of the SQL-89, SQL-92 specifications and few are from those introduced in SQL-99.

Selected Adds:
Identify and Remove Duplicate records
Using ROW_NUMBER() function with PARTITION BY
Data selection that depends on what time is it now
Procedure that splits character string to words
UDF Min/Max value function in MS-Access SQL
MS-SQL. Build geography grid with given cell size
PostGIS. Find nearest point to the given coordinates
Python script for searching and copying numerous files

This archive includes more than 200 sql query examples (and procedures) usefull for learning sql programming technique, but is not a systematic SQL tutorial. If you need one, go to: Or: exists since 2007 and its purpose to share sql quering and programming expertise with broad audience.
Disclaimer: All materials enclosed or downloaded from this site is not associated with any guarantees. Please read carefully and understand each example prior to executing it, especially on production environments.