db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <kh160...@clustra.norway.sun.com>
Subject Re: VALUES Query Question
Date Fri, 12 Dec 2008 10:17:45 GMT
MassimoH <MassimoHeitor@gmail.com> writes:

> I want to do a query like this:
>
> SELECT Months.????, (SELECT SUM(Amount) FROM Sales WHERE SaleMonth =
> Months.????) AS Sales
> FROM (VALUES '2008-01-01', '2008-02-01', '2008-03-01', '2008-04-01',
> '2008-05-01', '2008-06-01', '2008-07-01') AS Months;
>
> However, when I use VALUES in a sub-query, I don't see how to reference the
> column. Basically, how can I get the above query to work?

Hi Massimo,

You can also rename columns with the AS clause. For instance, you can
replace "AS Months" with "AS Months(x)", and then you can reference the
column as Months.x.

-- 
Knut Anders

Mime
View raw message