Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT Statement

Status
Not open for further replies.

garak76

Programmer
Sep 10, 2003
5
DE
Hi everybody,

I got a problem with mysql 3.23.56 with windows xp.
I wrote this SQL Statement and it worked fine:

"SELECT COUNT(*) as SchubAnzInGr,
Round((TO_DAYS(NOW()) - TO_DAYS(SichereDiagnose)) / 365)
as ErkDauer
FROM Diagnostik, Schuebe
WHERE Diagnostik.MitgliedsNr = Schuebe.MitgliedsNr
GROUP BY ErkDauer";

But in the next step I have to work with the temporary Fields SchubAnzInGr and ErkDauer like this:

SELECT AVG(SchubAnzInGr) as AVGSchubAnz From ...
Group By ErkDauer

Thanx for any help
Frank

p.s.

Maybe something like :
SELECT AVG(SchubAnzInGr) as AVGSchubAnz FROM (SELECT ...)
Group by ErkDauer???
 
SQL doesn't work that way.

The "AS" clause does not make those columns available to successive queries. It just provides aliases for columns that can be referred-to within the query or by applications processing the return of the query.

If you want those values to be available to successive queries, I recommend that you insert the values into a temporary table.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Yes I know its no longer available, but isnt there
a possibility with cascading SELECT statements like I mentioned in the end of my question ???

If there no way, how do I work with temporary tables,
do you know a good docu ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top