orbital 123
Veteran XX
So I have a sql problem that someone here might be able to help with.
Essentially it looks like so:
I'm having trouble with the inner join as I am no directly referencing a table in my from, it's a result set.
Anyone SQL guru's out there know what you do in a situation like this? Besides hope and pray?
Essentially it looks like so:
Code:
SELECT col1, col2, col3, col4, count(col2)
FROM
(SELECT CASE
WHEN col1 BETWEEN '#' AND '#' THEN 'val1'
WHEN col1 BETWEEN '#' AND '#' THEN 'val2'
WHEN col1 BETWEEN '#' AND '#' THEN 'val3'
END, col2, col3, col4 FROM tbl1)
INNER JOIN
tbl2 t2
ON
etc.......
I'm having trouble with the inner join as I am no directly referencing a table in my from, it's a result set.
Anyone SQL guru's out there know what you do in a situation like this? Besides hope and pray?