Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Conversion
Message
De
29/09/2011 13:11:30
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
SQL Conversion
Divers
Thread ID:
01525186
Message ID:
01525186
Vues:
112
Hello all, I am porting a VFP app to NET and SQLServer. I have a fairly complex SQL SELECT that I need to rewrite to be compatible with SQLServer 2008. It includes some lines like this:
select ;
	sum(iif(month(receiveddate)=7,amount,000000000000.00)) as jul, ;
	sum(iif(month(receiveddate)=8,amount,000000000000.00)) as aug, ;
	sum(iif(month(receiveddate)=9,amount,000000000000.00)) as sep, ;
So far I have not been able to figure out how to work the IIF statements into the new code. Can someone give me some ideas here?
Thanks

PS If you are interested, here is the whole thing.
select crsb.category, orderby, jul,aug,sep,oct,nov,dec,Jan,Feb,Mar,apr,may,jun,FisYear, ;
	(select sum(amount) from rta_revenues where fisyear = crsB.fisyear) as FYTotal, ;
	0000000000.00 as julPrior, ;
	0000000000.00 as augPrior, ;
	0000000000.00 as sepPrior, ;
	0000000000.00 as octPrior, ;
	0000000000.00 as novPrior, ;
	0000000000.00 as decPrior, ;
	0000000000.00 as janPrior, ;
	0000000000.00 as febPrior, ;
	0000000000.00 as marPrior, ;
	0000000000.00 as aprPrior, ;
	0000000000.00 as mayPrior, ;
	0000000000.00 as junPrior, ;
	0000000000.00 as julTotal, ;
	0000000000.00 as augTotal, ;
	0000000000.00 as sepTotal, ;
	0000000000.00 as octTotal, ;
	0000000000.00 as novTotal, ;
	0000000000.00 as decTotal, ;
	0000000000.00 as janTotal, ;
	0000000000.00 as febTotal, ;
	0000000000.00 as marTotal, ;
	0000000000.00 as aprTotal, ;
	0000000000.00 as mayTotal, ;
	0000000000.00 as junTotal, ;
	0000000000.00 as priorTotal ;
	from rta!rta_revenuecategories crsA;
	inner join ( ;
	select ;
	sum(iif(month(receiveddate)=7,amount,000000000000.00)) as jul, ;
	sum(iif(month(receiveddate)=8,amount,000000000000.00)) as aug, ;
	sum(iif(month(receiveddate)=9,amount,000000000000.00)) as sep, ;
	sum(iif(month(receiveddate)=10,amount,000000000000.00)) as oct, ;
	sum(iif(month(receiveddate)=11,amount,000000000000.00)) as nov, ;
	sum(iif(month(receiveddate)=12,amount,000000000000.00)) as dec, ;
	sum(iif(month(receiveddate)=1,amount,000000000000.00)) as Jan, ;
	sum(iif(month(receiveddate)=2,amount,000000000000.00)) as Feb, ;
	sum(iif(month(receiveddate)=3,amount,000000000000.00)) as Mar, ;
	sum(iif(month(receiveddate)=4,amount,000000000000.00)) as apr, ;
	sum(iif(month(receiveddate)=5,amount,000000000000.00)) as may, ;
	sum(iif(month(receiveddate)=6,amount,000000000000.00)) as jun, ;
	FisYear, category ;
	from rta_revenues ;
	group by FisYear, category) crsB;
	on crsA.category = crsb.category ;
	order by FisYear, orderby ;
	into cursor crsRpt readwrite
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform