| jeff.davis@usnr.com 2005-10-29, 8:23 pm |
| Hoping someone can help me. I am using sybase 5.5.05 and am having a
problem joining two statements.
My first query works and puts the data the way I want to view it:
select
costs.equip, costs.eff_date as start_date,
min(costs_2.eff_date) as end_date, costs.amount
from
costs left outer join "costs" costs_2 on
costs.equip=costs_2.equip
where
costs_2.eff_date > costs.eff_date AND
costs_2.eff_date <= today()
group by
costs.equip,
costs.eff_date,
costs.amount
However I am having trouble trying to get this query to be used like a
table so that I can create one query to do what I want.
Is there a way to do something like the following:
(
select
costs.equip, costs.eff_date as start_date,
min(costs_2.eff_date) as end_date, costs.amount
from
costs left outer join "costs" costs_2 on
costs.equip=costs_2.equip
where
costs_2.eff_date > costs.eff_date AND
costs_2.eff_date <= today()
group by
costs.equip,
costs.eff_date,
costs.amount
)
as myRange (equip, start_date, end_date, amount)
so that I can then in a larger query use this as a table and reference
myRange."start_date"
|