Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Upgrading, GROUP BY question
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01313609
Message ID:
01313635
Vues:
9
>>I'm upgrading a VFP7 app to VFP9. I understand that all non-agregate fields should be included in the GROUP BY clause. Am I mistaken to assume that the primary group should be listed first? If the other fields are included only to make the select work, does it matter whatorder they are listed in?
>>
>>Is there a downside to listing many fields in the GROUP BY clause?
>>
>>Is there a better (or proper) way to handle this?
>>
>>Thanks in advance for any help clarifying.
>
>Yes, primary group should be listed first. For the rest you may use some aggregate function such as min (max) if you don't want to list these fields in the GROUP BY, e.g.
>
>select myGroupField, max(myOtherField) as myOtherField, etc. .... group by 1
Here is an example of one of our selects that we are using to create a report. It just seems that there would have to be some downside to including all these fields on the GROUP BY clause.

Am I missing a proper way to accomodate this (again)?
SELECT DISTINCT shp_air.booking_no, cntnr.qnty, shp_air.vessel_txt, shp_air.pier, shp_air.voyage, ;
                shp_air.name_depc, shp_air.depart, shp_air.eta_dest_t, shp_air.fldate1, shp_air.dest_port, ;
		shp_air.pier_tm, shp_air.eta_dest_d, shp_air.pier_dt, lots.order_date, ;
		lots.shipnm, lots.shipattn, lots.shipphn, lots.shipfax, lots.nat_memo, lots.comments, ;
		lots.shpord_nos, lots.pieces, lots.unit_wt, lots.wt_tot, lots.unit_vol, lots.vol_tot, ;
		lots.consname, lots.consphn, lots.consfax, lots.consattn, lots.cons_acct, lots.cont_fld, ;
		lots.agt_o_name, lots.agt_d_name, lots.orig_ctyst, lots.orig_cntry, lots.ff_agent, lots.sig_off, ;
		hwb_chg.chg3_desc, hwb_chg.chg3_pp, hwb_chg.per3, lots.shp_air_id, LOTS.HWBNO_XTND, ;
		hwb_chg.chg4_desc, hwb_chg.chg4_pp, hwb_chg.per4, ;
		hwb_chg.chg5_desc, hwb_chg.chg5_pp, hwb_chg.per5, ;
		hwb_chg.chg6_desc, hwb_chg.chg6_pp, hwb_chg.per6, ;
		hwb_chg.chg7_desc, hwb_chg.chg7_pp, hwb_chg.per7, ;
		hwb_chg.chg8_desc, hwb_chg.chg8_pp, hwb_chg.per8, ;
		lots.ultd_eta_d, lots.ultd_eta_t, lots.ultd_ctyst, lots.dlvry_dt, lots.ultd_cntry  ;
	FROM shp_air, lots, cntnr, hwb_chg ;
	WHERE lots.lots_id = ret_val ;
		AND lots.lots_id = hwb_chg.lots_id ;
		AND shp_air.shp_air_id = lots.shp_air_id ;
		AND cntnr.shp_air_id = shp_air.shp_air_id ;
	GROUP BY lots.hwbno_xtnd ;
	INTO CURSOR bookingrpt
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform