devxlogo

March 25, 1997

Comparing Aggregate Results

Question: [Joe Celko’s Promo Puzzle]Let’s assume that you have just gotten a job as the sales manager for a department store. Your database has the following two tables. One is

Calculating Averages Using Clock Times

Question: Joe Celko’s Store Survey Puzzle]You are collecting statistical information stored by the quarter hour. What your customer wants is to get information by hour ? not on the hour.

Finding the Most Recent and Consecutive Data

Question: [Joe Celko’s Pension Plan Puzzle]Luke Tymowski, a Canadian programmer, posted an interesting problem on the MSAccess forum on CompuServe in 1994 November. He was working on a pension fund

Finding Data Based on Contents of Multiple Columns

Question: Joe Celko’s Playing the Ponies Puzzle]You have just become the database manager for Eddie Franco “the Doctor” Coddetti. He keeps records on horse races for statistical purposes and his

Tax Problem Puzzle

Question: [Joe Celko’s Tax Problem Puzzle]I got this one from Richard S. Romley, via CompuServe. We were engaged in a debate about Sybase’s old T-SQL versus ANSI/ISO SQL-92. I assume

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

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

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