First, let me say 'what an absolutely horrid statement'. :)

The table names are terrible
The column names are terrible
Hard-coded values are used
A Select * is used.

There are *many* things that need to be done to this database, not to mention the statement ;)

However, back to the problem at hand. I would gladly convert this for you except that I have no idea what the following part does:

select distinct(rl0to#),rl0fr#

How can you select distinct on only one column from a column list?

If you could please explain, with a simple example, what this syntax would return, I can convert the rest of the statement for you.

- Chris