Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sum and count
Message
De
06/11/2013 05:54:22
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
05/11/2013 07:41:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01587291
Message ID:
01587391
Vues:
35
You can simplify the iif() expressions a bit by using the max() function instead, for example:

... sum(max(column5, 0))

>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
>
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform