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 Like 23 Dislike
Previous forums Next forums
Other forums

Multiple PHP errors when clicking a link..and..removing a ghost..
Hi - I have 2 problems with a new website - homeswapvacations.com, which I need help solving.

Confused with Loop
guys, i got confused with Looping...this is the case

I have 3 stocks, let say "Stock A&q

Lining up columns nicely.
Hello everyone, I'm having problems with making columns line up properly. Here is my code:

Progress bar tracking file downloads
Hey guys, was wondering if there was a way to track how far a file has been downloaded. I know there

Unidentified index error in a simple form
I have been trying to make an HTML form that is handled by a PHP script. So far my attempts to get i

How can use this array as a key?
Say I have this array for example:


print_r($array);

Prints:
Code: [Select]Array

Polymorphism
Was wondering if someone could explain this a little better to me. I had always assumed that it had

PHP FTP connect doesn't work with correct login
Hi!

i am working on this test code:
Quote<?php

$ftp_ser

PHP using IF to display error
i have a MySQL query and i want to display 1 thing only if the number of affected rows is >=1

CHMOD script
Hi,

I need a script to read all files in a folder and set to 777.

Can anyone help out

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