Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sum and count
Message
From
05/11/2013 09:11:51
 
 
To
05/11/2013 07:41:17
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01587291
Message ID:
01587296
Views:
59
What happens if you use SUM(1) instead of COUNT()?
CAST(sum(IIF((column5>0), 1, 0)) AS N(4)) AS File5,;
CAST(sum(IIF((column8>0), 1, 0)) AS N(4)) AS File6;
>hi all,
>
>i try this code to get result as 9 ,30.43,3,7
>but the result is 9,30,43,10,10
>
>SELECT column27,;
>              CAST(sum(IIF((column5>0)  , column5, 0)) AS N(14,2)) AS File3,;
>              CAST(sum(IIF((column8>0)  , column8, 0)) AS N(14,2)) AS File4,;
>              CAST(count(IIF((column5>0)  , column5, 0)) AS N(4)) AS File5,;
>              CAST(count(IIF((column8>0)  , column8, 0)) AS N(4)) AS File6;
>              FROM wtable2 ;
>GROUP BY column27;
>INTO CURSOR crsTest 
>index on padl(alltr(column27),10,"0")   tag aaa
>BROW NORMAL
>
>
>Column27	column3 column4 Column5   	             Column8   	
>9    	  a             42            12	                       0	
>9    	  a             42            0	                      15	
>9    	  a             42            0	                      12	
>9    	  a             42            0	                       7	
>9    	  a             42            5	                       0	
>9    	  a              .             0	                       3	
>9    	  a              .             0	                       1	
>9    	  a              .             0	                       1	
>9    	  a              .             0	                       4	
>9    	  a              42          13	                       0
>
>result as 
>Column27     sum(column5)      sum(column8)        count(column5)      count(column8)
>     9               30                              4                      3                                 7
>
Previous
Reply
Map
View

Click here to load this message in the networking platform