Tip Bank

DevX - Software Development Resource

Solving Multiple Conditions Within a Group

Question: [Joe Celko’s Work Order Puzzle]Cenk Ersoy asked this question on the Gupta Forum on CompuServe. He has a table that looks like this: CREATE TABLE Projects (workorder CHAR(5) NOT

DevX - Software Development Resource

Sorting “Codes” within a Column

Question: I have a table that consists of numbers stored as characters.How can I sort them in numerical order? I can’t convert thisfield to numeric because some content is alpha

DevX - Software Development Resource

CHECK Constraint To Avoid Overlapping Data

Question: [Joe Celko’s Reservations Puzzle]Since I spend a lot of time this column talking about problems with the order of execution of SQL statements, it is only fair that I

DevX - Software Development Resource

Finding the Greatest Lower Bound

Question: [Joe Celko’s Sales Gaps Puzzle]Given a table “sales” and a column “saledate” and “customer,” is there a way to get the average number of days between sales dates for

DevX - Software Development Resource

Indexes in SQL

Question: Is it possible to set indexes between tables in SQL expression? Answer: You can establish indexes on SQL tables, but SQL indexes do not create an implied relationship between

DevX - Software Development Resource

Wildcard Searches in SQL

Question: Are wildcards allowed when trying to matchthe contents of a textfield as in the following example? SELECT * FROM Database WHERE textfield = ‘B*’ Answer: Yes, but you’ll need

DevX - Software Development Resource

Calculating Running Totals

Question: [Joe Celko’s Quantity on Hand Puzzle]You are now the guy in charge of the company inventory. You get requisitions that tell how many widgets people are putting into a