[thelist] [SQL] SELECT Question

Jacques Capesius Jacques.Capesius at compellent.com
Thu May 26 14:19:03 CDT 2005


Hi folks,

I am building a rather cumbersome SQL Query that has two sub-queries in
it, and I'm trying to avoid having to add in a third (and likely a
fourth) Here's the general query layout.

------------------------------------------------------------
SELECT
(
	*SUBQUERY 1*
) AS 'Sales',
(
	*SUBQUERY 2*
) AS 'Quota'
FROM...
------------------------------------------------------------

What I want to do is something like this.

------------------------------------------------------------
SELECT
(
	SUBQUERY 1
) 
AS 'Sales',
(
	SUBQUERY 2
),

[Column 'Sales'] / [Column 'Quota'] AS 'Percent to Quota'
FROM...
------------------------------------------------------------

Is there a way to directly refer to a SELECT clause item by alias or
column number (as in ORDER BY 1,2) so I can avoid having to write
another set of subqueries to calculate the result of subquery 1 /
subquery 2?

TIA and thanks for reading.

-jacques :)



More information about the thelist mailing list