Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
HAVING Clause in SQL
Message
 
 
À
03/07/2003 09:20:07
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00806508
Message ID:
00806510
Vues:
17
This message has been marked as the solution to the initial question of the thread.
Hi Renoir,

The HAVING clause is applied after grouping is done. In your case it only includes records that have the same values in xxxZERO and xxxOther group of fields.

>Can anyone help me understand what the HAVING clause is doing in this statement?
>
>Thanks! Renoir
>
>
>SELECT a.*,;
>	SUM(IIF(b.acct_id = 0, 1, 0)) cntZERO,;
>	SUM(IIF(b.acct_id = 0, b.econ, 0.00)) econZERO,;
>	SUM(IIF(b.acct_id = 0, b.emat, 0.00)) ematZERO,;
>	SUM(IIF(b.acct_id = 0, b.nProfits, 0.00)) PSZERO,;
>	SUM(IIF(b.acct_id <> 0, 1, 0)) cntOTHER,;
>	SUM(IIF(b.acct_id <> 0, b.econ, 0.00)) econOTHER,;
>	SUM(IIF(b.acct_id <> 0, b.emat, 0.00)) ematOTHER,;
>	SUM(IIF(b.acct_id <> 0, b.nProfits, 0.00)) PSOTHER;
>	FROM temp1 AS a, acctcont AS b;
>	WHERE a.invnum = b.invnum AND a.contrib_dt = b.contrib_dt AND b.transtype = 'T';
>	GROUP BY a.invnum, a.contrib_dt;
>	HAVING ;
>		ABS(econZERO) = ABS(econOTHER) AND ;
>		ABS(ematZERO) = ABS(ematOTHER) AND ;
>		ABS(PSZERO) = ABS(PSOTHER) ;
>		AND cntZERO = cntOTHER;
>	INTO TABLE temp
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform