Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query design help
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Desktop
Divers
Thread ID:
01365555
Message ID:
01365703
Vues:
8
Sergey,

What would happen if both nSVC and nPVC are 0 at the same time?

>Daniel,
>
>Try
>
>SELECT dpvc.cEDP, dpvc.nPVC, dsvc.nSVC 
>	FROM (
>			SELECT cEDP, nPVC FROM mytable  mt1 
>		 		WHERE dUpdatedOn = (SELECT MAX(dUpdatedOn) FROM mytable WHERE cEDP = mt1.cEDP AND nPVC <> 0 )
>		) dpvc
>	JOIN (
>			SELECT cEDP, nSVC FROM mytable  mt1 
>				WHERE dUpdatedOn = (SELECT MAX(dUpdatedOn) FROM mytable WHERE cEDP = mt1.cEDP AND nSVC <> 0 )	
>		) dsvc ON dsvc.cEDP = dpvc.cEDP 		
>
>>
>>I have the following SQL table:
>>
>>iId cEDP nPVC nSVC dUpdatedOn
>>1 123 10.12 15.30 12/1/2008
>>2 123 12.12 0.00 12/2/2008
>>3 555 35.40 0.00 12/2/2008
>>
>>
>>I would like to group by the cEDP and when duplicate EDP exists use max(dUpdatedOn) to get the nPVC and nSVC values except for when nPVC or nSVC value is 0.00. Based on the above data I would like the following results:
>>
>>
>>cEDP nPVC nSVC
>>123 12.12 15.30
>>555 35.40 0.00
>>
>>Thank you,
>>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform