On Mon, 5 Jan 2004, Hal Vaughan wrote:

> I've found an odd problem in queries.
>
> I have a lot of data regarding vehicle speeds in a survey.  All the data is in
> the form: xx/yy, for example 43/55 means that vehicle was clocked at 43 miles
> per hour in a 55 miles per hour zone.  80/55 means we have a serious speed
> demon, going 80 in a 55 zone.
>
> I need to be able to pull out data depending on speeds in relation to the
> speed limit, for example, find out how many are less than 55/55 or 45/45, or
> how many are more than 5 miles over (like 61/55 or 32/25).

mysql> SELECT SUBSTRING_INDEX(speed, '/', 1) AS clocked,
    ->   SUBSTRING_INDEX(speed, '/', -1) AS zone, ...
    -> WHERE SUBSTRING_INDEX(speed, '/', 1) > SUBSTRING_INDEX(speed, '/',
-1) AS zone


That is for finding all the speeders, for example.

cheers,
Tobias

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to