SELECT Syntax
Posted in 1999
Hi, considering the SELECT Syntax grammer of INFORMIX you are allowed to use Subqueries but only in the WHERE Clause. (or did I miss something?) Now why does the following statement work and give the wrigth result? QUERY: ------ select entg1.fgnr, entg1.fkto, entg1.leistungs_datum, entg1.anzahl - (select sum( entg2.anzahl_storno) from tee entg2 where entg2.fk_tdbnummer = 4779042940 and entg2.geschaeftsvorfall = "12" and entg2.fkto = entg1.fkto and entg2.fgnr = entg1.fgnr and entg2.leistungs_datum = entg1.leistungs_datum and entg2.betrag = entg1.betrag and entg2.storno_zeitstempel = entg1.storno_zeitstempel ) diff_anzahl, entg1.fk_tdbnummer, entg1.auftrag_nummer, entg1.auftrag_niederlass, entg1.storno_zeitstempel, entg1.faktgr_zeitstempel, entg1.anzahl_storno from tee entg1 where entg1.fk_tdbnummer =4779042940 and entg1.geschaeftsvorfall <> "12" order by entg1.fkto, entg1.auftrag_niederlass, entg1.faktgr_zeitstempel, entg1.fgnr, entg1.leistungs_datum, entg1.auftrag_nummer, entg1.storno_zeitstempel Estimated Cost: 2 Estimated # of Rows Returned: 1 Temporary Files Required For: Order By 1) mora.entg1: INDEX PATH Filters: mora.entg1.geschaeftsvorfall != '12' (1) Index Keys: fk_tdbnummer geschaeftsvorfall lfdnr Lower Index Filter: mora.entg1.fk_tdbnummer = 4779042940 This is the output of sqexplain.out and as you can see the Subquery is not listed in this output, but the result is OK. I looked at the documentation on www.informix.com but could not find anything regarding this "problem". Is this an undocumented feature or just a programers "mistake"? Thanks in advance Monika Rabold Bull GmbH Langen Robert Boschstr. 52 63225 Langen Tel: 06103/761-4225 Fax: 06103/761-4266 email: mora@swh600.langen.bull.de