Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compound Select
Message
 
 
To
28/08/2008 16:40:37
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01342599
Message ID:
01342821
Views:
9
>Given that this works
>select crsB.category, orderby, jul,aug,sep,oct,nov,dec,Jan,Feb,Mar,apr,may,jun,FisYear ;
>	from 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
>suppose now we want to add a field to the result "fytotal" that will total all amounts for all categories within a single fisyear? I tried adding a
>sum(amount) as fyTotal and a GROUP BY fisyear to the outside select but that didn't work.

Nice! We can try to use both now - projection + derived tables in one SQL statement.

Should I write it for you or the "projection" word would be enough for a hint?
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform