How to sum these output values


Posted on 16th Feb 2014 07:03 pm by admin

Hi

I need sum the month totals
SELECT region_name, area_name ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '07' THEN sales_target END) AS jul ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '08' THEN sales_target END) AS aug ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '09' THEN sales_target END) AS sep ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '10' THEN sales_target END) AS oct ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '11' THEN sales_target END) AS nov ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '12' THEN sales_target END) AS dec ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '01' THEN sales_target END) AS jan ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '02' THEN sales_target END) AS feb ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '03' THEN sales_target END) AS mar ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '04' THEN sales_target END) AS apr ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '05' THEN sales_target END) AS may ,SUM (CASE WHEN SUBSTR(yr_mth,5,2) = '06' THEN sales_target END) AS jun FROM sales_forecast WHERE REGION_NAME like nvl('®IONNAME','%') AND AREA_NAME like nvl('&AREANAME','%') AND yr_mth=nvl('&Year',substr(yr_mth,1,4))||NVL(DECODE('&Month','JAN','01','FEB','02','MAR','03','APR','04','MAY','05', 'JUN','06','JUL','07','AUG','08','SEP','09','NOV','11','DEC','12'),substr(yr_mth,5,6)) GROUP BY region_name, area_name ORDER BY region_name, area_name Requirment region_name, area_name, jul, aug ................ jun abc xyz 10, 20.....................30 ccc ggg 20, 30.....................40 total 30, 50 ...................70
Did you know?Explore Trending and Topic pages for more stories like this.
thanks
No comments posted yet

Your Answer:

Login to answer
245 Like 23 Dislike
Previous forums Next forums
Other forums

curl javascript problem
Hi Experts.
I'm new curl and wanna to get some info from this http://www.amadeus.net/

when

Check before inserting in DB ???
This is my code
---------------
if ( $_POST ['Submit'])
{{
$username = $_POST ['usernm

turning an array into a string then poping it into a db
Hi im just wondering how you get a requested array into a single string then pop it into the db so f

"From field" in PHP email form
I used a wizard to create a PHP email form. I was able to customize it with the exception of the Fr

EU VAT Package 2010
Does any one know whether SAP will be developing new reporting functionality due the new VAT rules t

Warning: mysql_num_rows() expects parameter 1
When i add quote at the end of this link
example:http://localhost/articlemania/category.php?cid=3

Cron Job and Output
I have php codes running under a cron job.
But everytime i output (echo) , it comes out as comple

MYSQL gen help
This is my Mysql gen. can anyone tell me why this echos

MID(networkset.networkid, 3, 3) AS &q

Simultaneous select/update/insert
Hi

How would I need to go about when 2 users update a single row simultaneous? And how would

Need Help with a query
Hello,
For some reason I am just not getting the right answer when I do this query and not quite

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash