Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
HAVING Clause in SQL
Message
From
03/07/2003 09:20:07
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
HAVING Clause in SQL
Miscellaneous
Thread ID:
00806508
Message ID:
00806508
Views:
51
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
Next
Reply
Map
View

Click here to load this message in the networking platform