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
thanks
No comments posted yet
Your Answer:
Login to answer
245
23
Other forums
A little help needed passing hidden values to next page
I have a page that has hidden values in a form.
example
Code: <input name='signupID
Help: calling function
Hi,
Is it possible to call a php function on page close?
If yes, could you explain how and whe
str_replace help
Hey there,
I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean
phpMailer not working ..........
HI,
I was playing with the phpMailer script and tried to send a smiple mail using their test scri
Splitting Attributes
SQL> SELECT I_NAME, substr(I_NAME,1,instr(I_NAME,'O')) "First part",
substr(I_NAME, IN
header redirect problems? please help
Ok i am making a site that generates youtube thumbnails and i am generating an image that displays 1
help, header() is not working!
Hello, I have this code:
<?php
/**
* @author samoi
* @copyright 200
pagination numbering pattern
Hello,
I have following code which works great for pagination. but i have small issue now.
need help with php get
i have a option box that gets filled with dates, but how do i get once the option value has been cli
Bluetooth RSSI & VIsta
Okie I got 4 Bluetooth adapters, a DBT-120 by Dlink, A Zonet Microsoft Bluetooth which is what I use