[thelist] Re-Using A Sub Query Value

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Thu Jun 22 13:05:42 CDT 2006


		I still don't understand why you're using a subquery here.  Wouldn't the following make more sense?

SELECT a.id1, a.item 2, b.item3, a.item4+b.item3 AS GrandTotal 
FROM table1 a, table2 b, blah blah
WHERE b.id = a.id and blah blah 

Peter

				From: "Casey Crookston" caseyc at IntelliSoftmn.com

Okay, this is a continuation of my previous post. Once you have
selected a value in a sub query, is it possible to reference that value
without performing the sub query again?

Example:

SELECT a.id1, a.item 2, (select b.item3 FROM blah WHERE b.id = a.id) AS
myTotal, a.item4+myTotal AS GrandTotal FROM blah blah WHERE blah blah

Does that make sense?

Thanks,

Casey



More information about the thelist mailing list