[thelist] SQL: summing and counting the same field, based on value

Tab Alleman talleman at Lumpsum.com
Tue Jun 13 13:42:15 CDT 2006


Does this help?

SUM(
	CASE 
		WHEN Type=9 THEN 1
		ELSE 0
	END
) AS Type9Count

> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org]On Behalf Of Canfield, Joel
> Sent: Tuesday, June 13, 2006 12:39 PM
> To: thelist at lists.evolt.org
> Subject: [thelist] SQL: summing and counting the same field, based on
> value
> 
> 
> My table has (among others) fields for type, start, and end.
> 
> I need to get the total duration for all four possible types 
> (got that)
> *and* the count where type = 9
> 
> the syntax just isn't coming to me
> 
> help?
> 
> joel
> -- 
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester 
> and archives of thelist go to: http://lists.evolt.org 
> Workers of the Web, evolt ! 
> 



More information about the thelist mailing list