Home > Archive > SQL Anywhere database > October 2005 > Use Select statement as table?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Use Select statement as table?
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"

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com