Calculation grouping using decode statement?
I have 4 sales reps who are numbered 9801, 9802, 9803 VRP, 9804.I have 3 support staff that support accounts by virtue of these representatives of REPS 1, 2, 3
Support rep 1 will support the commercial attaché 9801 & 9802
Support rep 2 will support the commercial attaché 9802 and 9803
Support rep 3 will support the commercial attaché 9803 & 9804.
Initially, I had a report which gave the results for all listed sales reps. The representatives of support and then imported it into excel and delete the records of the sales reps that they do not need.
I want to create a page filter that will support rep select its name in a drop-down which shows only sales reps they support. So support rep 1 can select their name from the drop down and the report would only show information for the commercial attaché 9801 & 9802.
I tried to do this with a calculation using the decode statement, but it does not work. It seems only to associate support rep to each sales representative. Is there a way to accomplish the grouping I want?
DECODE (put into commercial service Rep.Sales,
9801,'REP ' 1,.
9802,'REP ' 1,.
9802, ' REP 2',
9803, ' REP 2',
9803, ' REP 3',
9803, ' REP 4'.
9804, ' REP 4'.
"ERROR")
Hello
I don't think you can do it easily if you want to use a filter on the page. This is because if a row is returned by the database that has a sales of 9802, then, the line must be on 2 pages.
You can create a parameter to select the support rep and use this setting to select the records. Therefore, if the parameter is p_support_rep then you have a condition like:
(: p_support_rep = 'REP1' AND sales_rep IN (9801, 9802)) OR
(: p_support_rep = "REP2' AND sales_rep IN (9802, 9803)) OR
(: p_support_rep = "REP2' AND sales_rep IN (9803, 9804))
If you really need to use a filter on the page, then you will need to use a generator of line to create a line for each support rep and to join your generator line report by using a report similar to the one above. You can search for "Generator line" of this forum, or check out the learndiscoverer blog (http://learndiscoverer.blogspot.com/2008/10/row-generators.html) for more details.
Rod West
Tags: Business Intelligence
Similar Questions
-
Hi I am writing a query for data migration and it there a few transformations in this query and one of these is like this:
Select a.col1, a.col2, b.col1, b.col2, tabl1 a.col3 a, b from table2
where a.col5 = b.col5
in this I need to transform a column say a.col3
If a.col3 is
XX_ then XX
X_ and Y_ then XY
X_XYZ_A or Y_XYZ_A, then XZ
XYZ or XX_XYZ then YZ
YY_ then YY
Can I use decode statement to do this with susbstr if charatcters son how I have to susbtr that some of the values to be transoformed are three characters and some are more than three
Thank you
Manoi
Published by: user518071 on August 12, 2011 06:16Hello
I suggest you use CASE... WHEN instead of DECODE, because you will have more flexibility.
Here is the link:
http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/expressions004.htm#SQLRF20037for example, you can do something like this:
CASE WHEN substr(a.col3,1,3)='XX_' then 'XX' WHEN substr(A.col3,1,2) in ('X_','Y_') then 'XY' WHEN substr(a.col3,1,7) in ('X_XYZ_A','Y_XYZ_A') then 'XZ' ... END
Hope it helps.
Kind regards
Sylvie -
Mark to base using DECODING works is not as expected.
Version: 11.2.0.3
Platform: RHEL 5.8
I try to use the DECODE function.
In the example below, if the meeting looks for the string 'Enterprise', then decoding should
return 'Enterprise '. But it doesn't seem to work.
I thought that some hidden character was the origin of the problem, so I used the TRIM. But no luck.
SQL > create table t (banner varchar2 (80));
Table created.
SQL > insert into values t ('Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production');
1 line of creation.
SQL > commit;
Validation complete.
SQL > select * from t;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
SQL > select * from t where the banner as "database % ';
BANNER
--------------------------------------------------------------------------------
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
-Try to use decode it. If the meeting looks for the string 'Enterprise', then return 'Enterprise '.
-Although the string "Business" is present, decode doesn't seem to work.
-I tried to use the upper trim. But no luck.
SQL > select 'EDITION', decode(banner,'%Enterprise%','Enterprise','Standard') edition of t which the banner like '% database % ';
' EDITION EDITIO
------- ----------
Standard EDITION
SQL > select 'EDITION', decode (trim (banner), '% company %', 'Enterprise', 'Standard') edition of t where trim (banner) like '% database;
' EDITION EDITIO
------- ----------
Standard EDITION
SQL > select 'EDITION', decode (upper (trim (banner)), "% COMPANY % ', 'Enterprise', 'Standard') edition of t where upper (trim (banner)) as"DATABASE % ';
' EDITION EDITIO
------- ----------
Standard EDITION
SQL >
Don't understand why decode cannot see the string "business".
BTW. Where is the Preview button?
Hi Ram,
Decode the will just exactly the result of research and the return value if it matches. This is the way DECODE and CASE work.
For example: DECODE(deptno,10,'Accounts',20,'IT')
So please adjust your statement accordnigly. Use INSTR, or REGEXP_COUNT.
See the example below.
SELECT decode(regexp_count(banner,'Express'),1,'Express Edition') FROM v$version;
In the new forums, I think that we don't have a preview button to see our post before posting.
See you soon,.
Suri
-
Hello
I try to do the following in my report:
If an employee is a family name. (dot) or a name of. (dot), the report does not display a point. An employee name consists of the family name, first name and middle name, which should all be concatenated sets. An attempt to achieve this goal, I have the following statement in my report:
Decode (e.Surname, '.', (LTRIM (RTRIM ((INITCAP (e.FIRST_NAME))) |))) » '|| INITCAP (e.MIDDLE_NAME))),
e.FIRST_NAME, '.', (LTRIM (RTRIM ((INITCAP (e.Surname))) |)) » '|| INITCAP (e.MIDDLE_NAME))),
(LTRIM (RTRIM ((INITCAP (e.SURNAME))) | ',' |)) INITCAP (e.first_name) | » '|| INITCAP (e.MIDDLE_NAME))) as emp_name
E employee
Problem: The above statement only works for employees with the name of. (dot). It doesn't for the first names of dot. How to use the decode statement OR is there another way to do it without using the CASE statement?
It seems my decode statement does not work with 2 different fields (name, first name) tested within the decode statement. Thank you.LTRIM and RTRIM the comma too:
select rtrim(ltrim(rtrim(ltrim(', Somename ,',','),','))) Name from dual; NAME -------- Somename
-
Can I use DECODE or CASES when it is in this context?
Hi, I have a query which goes like this but does not work:
{
SELECT NVL (SUM (NVL(r.cload,0) * NVL(r.duration,0)), 0)
IN saidi_sum_trip_caused_by
SPM_REL_IND_TMP r
WHERE substr(r.scode_trip_caused_by,6,4) in ('N001', 'N002', 'N003', 'N004', 'N005', "N006", "N007")
AND (r.cload <>0 r.cload GOLD IS NOT NULL)
AND DECODE (R.CLASSIFICATION_TRIP, 't', r.duration < = 5, )
r.Duration > 5);
}
It seems that there is a problem with my DECODE statement since I've noticed that when you use the DECODE function, a column is assimilated before the DECODE. However, in this case I can't equate the value of r.duration for DECODING since if the value of R.CLASSIFICATION_TRIP is ' t "then I should use < = I use >." How can I go about it? Thank you.try all the Subforums are you not
go here:
-
DECODE statement and the argument limits
No one knows the number of arguments that the DECODE statement allows you to enter. I currently have 863 and it gives me an error message when I try to run the query.
Database - ORA-00939 error: too many arguments for the function.
Thank you
ChrisHello
You still have too many parameters your decodes, the limit is 250 so you can enter only 124 values and decoded. I would like to nest decodes by doing:
DECODE (point, "c1", "v1", "c2", "v2", "c3", "v3",..., DECODE (point, 'c4', 'v4', 'c5', 'v5', 'c6', 'v6',..., DECODE (...)))
Alternatively, you can for example use case
WHEN BOX point IN (
END) Rod West
-
I have problem with value NULL when the use CASE statement please help this question
I have problem with value NULL when the use CASE statement please help this question
Table: digital_val
SNO cl C2
1 San1 11
2 22 San2
Actual result: expected to A B
A B 11 22
11 NULL
22 NULL
query:
Select case when c1 = "san1" then c2,.
case If c1 = "san2" then c2 B
of digital_val
I'm more curious why, when you select 2 rows, you expect a result of row?
WITH digital_val
AS (SELECT 1 AS 'Sno', 'San1"C1, c2 FROM DUAL 11)
UNION ALL
2 SELECT AS 'Sno', 'San2"C1, c2 FROM DUAL 22)
SELECT CASE WHEN c1 is "San1" THEN END AS A c2.
CASE WHEN c1 = "San2" THEN END AS B c2
OF digital_val;
With no other input, if you select 2 rows, you get 2 rows. One of the other solutions use a max function, but is this really what you want, does not specify?
-
Hello
I need to use decode condition in where clause in such a way that if the respective column is null then consider the corresponding column
for example
Fee_date Fee_refund_date 10 OCTOBER 05 12 NOVEMBER 05 11 JANUARY 06 16 FEBRUARY 06 I have a request in place as below where p_fee_flag will be passed as either FEES or set to null, I check another condition as if p_fee_flag is null then fee_date must be set to null when comparing fee_refund_date between TRUNC (BKT. ACT_START_DATE) AND TRUNC (BKT. ACT_END_DATE
SELECT 1
BUCKET BKT
WHERE DECODE (P_FEE_FLAG, 'FEES', TRUNC(FS.) FEE_DATE), TRUNC (FS. FEE_REFUND_DATE))
BETWEEN TRUNC (BKT. ACT_START_DATE) AND TRUNC (BKT. ACT_END_DATE)
944524 wrote:
Hello Alberto,.
Thank you that's what I ask but is it possible to verify the condition even using decode
Yes, it is possible, but why?
Just replace the query in this way:
select * from fee_table f where exists(select 1 from bucket b where decode(:p_fee_flag, 'FEE', f.fee_date, f.fee_refund_date) between b.act_start_date and b.act_end_date) and decode(:p_fee_flag, 'FEE', null, f.fee_date) is null;
Kind regards.
Alberto
-
using the statement and pagebox to spend
I am very new to javascript, but I'm trying to write a small script to provide automation based on the size of the page.
I know that my current document is one of the cases listed, but I can't get the switch statement below to acknowledge.
Any help would be greatly appreciated. I use Acrobat Pro 9. Thank you
function test() {}
var pSize = this.getPageBox ("Crop");
App.Alert (pSize, 3);
{Switch (psize)}
case '0,612,792,0': //A
App.Alert ("Page size", 0);
break;
case '0,792,1224,0': //B
App.Alert ("B size Page", 0);
break;
case '0,1224,1584,0': //C
App.Alert ("C size Page", 0);
break;
case '0,1584,2448,0': //D
App.Alert ("D size Page", 0);
break;
by default:
App.Alert ("size of the Page Not Found!", 0); / / do this if all else fails
break;
}
}
You can try to convert the table to a string using the switch statement:
var pSize = this.getPageBox("Crop"); pSize = String (pSize); // Now, use switch statement as you have it.
-
Replace values with image using DECODE
I am struggeling to replace the values in a table with images using DECODE, as shown here'https://apex.oracle.com/pls/otn/f?p=21195:1:0:.
The query itself is no problem and works great:
SELECT JOB_NAME Job status, DECODE(ENABLED, 'TRUE', '<img src="/i/orcl/up.gif">', 'FALSE', '<img src="/i/orcl/down.gif">') AS
OF USER_SCHEDULER_JOBS
Easy as pie, but...
Somewhere along the line the support < and > are replaced by & lt; and & gt; and the quote with & quot;
"As a result, the browser displays literally < img src="/i/orcl/up.gif "> and no image.
What I'm doing wrong?
635160df-de20-4FE3-9807-b51b06b91919 wrote:
Please update your forum profile with a real handle instead of '635160df-de20-4fe3-9807-b51b06b91919 '.
Somewhere along the line of the support < and=""> are replaced by < and > and quotes with '. '.
Therefore, the browser displays literally and no image.
What I'm doing wrong?
The column attribute the text to display as should be the Standard report column rather than the default display text (escape special characters).
-
See the grouping using API BC recovery products
How can I retrieve products by the group using recovery API BC?
Thanks for the quick response.
It solves the problem by defining condition where 'GroupingDefault': 'true '.
-
SELECT v_startdate, v_enddate,
(CASE WHEN SYSDATE BETWEEN v_startdate AND v_enddate THEN
'active '.
ON THE OTHER
'inactive '.
Status of END)
OF correction_tab;
Could you kindly guide as to how to use DECODE and get the desired result.
Thank you
Rami Reddy.You can, like this.
However, the CASE seems much clearer for me so why bother with a DECODING?sql> with correction_tab as 2 ( select trunc(sysdate)-1 as v_startdate, trunc(sysdate) as v_enddate from dual 3 union all 4 select trunc(sysdate) as v_startdate, trunc(sysdate)+1 as v_enddate from dual 5 union all 6 select trunc(sysdate)+1 as v_startdate, trunc(sysdate)+2 as v_enddate from dual 7 ) 8 SELECT v_startdate 9 , v_enddate 10 , CASE 11 WHEN SYSDATE BETWEEN v_startdate AND v_enddate 12 THEN 'active' 13 ELSE 'inactive' 14 END status 15 , decode ( sign(sysdate-v_startdate), 1, decode(sign(v_enddate-sysdate), 1, 'active', 'inactive'), 'inactive') as status2 16 FROM correction_tab 17 / V_STARTDA V_ENDDATE STATUS STATUS2 --------- --------- -------- -------- 12-DEC-12 13-DEC-12 inactive inactive 13-DEC-12 14-DEC-12 active active 14-DEC-12 15-DEC-12 inactive inactive
-
Buttons grouped in a State of a MSO, check the status of an another MSO
If you have an ESM which has the button together to the State, so that when it is pressed an overlay will appear. Because the button is grouped you can no longer control other States in other MSO. The problem I have is that if a LI is open in an MSO THAT and I click on another button in a different MSO I have now two OL open at the same time. I don't know if the button was not grouped with the State I could put each buttons have two actions, go first to the opposing stop Lo State and then to the State on the OL said, but the button that is grouped does not give me the option to select States outside its own MSO.
Grouped or ungrouped... is not serious. Once you put a button in an MSO
It can control only that MSO.
Bob
-
Total of page: display mode. Using If statements on page totals.
Hello
I've never posted Page totals in XML Publisher, and I came up against some problems:
I have a model:
<? for-each: G_DEPR_GROUP? >
<? DEPR_GROUP? >
<? MONTHLY_DEPRECEATION? >
<? NTC? > <? Add-page-total: CN; ' CNT'? >
<? end foreach? >
<? show page total: CN; ' C9G990D00 '; ' (C9G990D00)'? >
The total page for variable CN is not displayed despite that the CNT is NOT NULL digital input XML value. The line that contains the page total is displayed after the last record in the file.
If I change the location of <? end foreach? >:
<? for-each: G_DEPR_GROUP? >
<? DEPR_GROUP? >
<? MONTHLY_DEPRECEATION? >
<? NTC? > <? Add-page-total: CN; ' CNT'? >
<? show page total: CN; ' C9G990D00 '; ' (C9G990D00)'? >
<? end foreach? >
then the line for the total page appears immediately after each record in the report and the value of the CN is not displayed as well.
The task is to display an additional line will be dispalyed once per each page after records report that contains its page totals.
Another question: I would like to use select-statement of the CN variable to display different text in terms of the Page, for example, values
Choose a CN
When 30 then
"Thirty".
When 40 then
"Forty."
...
Is it possible to implement it on a page level?
Thank you!
Sergey
Edited by: Konung2000 09/16/2009 19:03inside loop, the syntax : To show the page total, add this in the footer or header.
-
duplicate group by using the statement
4 columns in the table named RRID1
RRI_ID
USER_ID
PROCESS_TYPE
FUNCTION
don't know how to make this request.
Need to learn where all the RRI_ID type = "INFO".
and USER_ID IS DOUBLE for this RRI_ID.
That's what some of the data looks like to...
PROCESSTYPE | USER_ID. FUNCTION | RRI_ID
3668 30287 817 INFO
3748 30287 817 INFO
4714 30287 817 INFO
4875 30287 817 INFO
4882 30287 817 INFO
4885 30287 817 INFO
3748 30288 818 INFO
4714 30288 818 INFO
4716 30288 818 INFO
4882 30288 818 INFO
4885 30288 818 INFO
819 30289 3668 INFO
819 30289 4716 INFO
819 30289 4875 INFO
819 30289 4882 INFO
819 30289 4885 INFO
3668 30290 820 INFO
4716 30290 820 INFO
4875 30290 820 INFO
4882 30290 820 INFO
4885 30290 820 INFO
3668 30291 821 INFO
4714 30291 821 INFO
4716 30291 821 INFO
4875 30291 821 INFO
4882 30291 821 INFO
Published by: user11299998 on October 1, 2010 07:21
Published by: user11299998 on October 1, 2010 07:22
Published by: user11299998 on October 1, 2010 07:22
Published by: user11299998 on October 1, 2010 07:22Something along the lines of...
select rri_id, user_id, process_type, function from ( select rri_id, user_id, process_type, function ,count(*) over (partition by rri_id, user_id) as cnt from rrid1 ) where process_type = 'INFO' and cnt > 1
Maybe you are looking for
-
The P70... A 4G phone that can not connect to 4G
I have a Lenovo P70 that I bought a month thinking that it is a 4G phone with long battery life and a good setup at an affordable price. Well, it has good battery life and most of all the functionality works very well to the satisfaction (not all). T
-
Satellite A100 - BIOS password not accepted after computer take part
(Sorry if this question has been asked before, I searched through topics, but too many subjects was found.) I have an old A100 for 3 years with no guarantee. I want to sell it so I took apart to clean dust. Everything for the motherboard. When everyt
-
When trying to install MP3 rocket I get an error 1316 or cannot access the jarlib jar java
I got this to mp3 rocket its not market is constantly (cannot access the c lib/mp3 rocket.jar) was taken from Yahoo answers. The same thing is happening to me and I also have the Error 1316, Mp3 Rocket program will install but not opened because of t
-
Transfer the email addresses and folders from one system to another using MS Outlook 2007
I spent more than 5 hours on a ton of sites including this menagerie without value on Microsoft. It's ABSOLUTELY ABSURD... All I want to do is copy my email addresses in my XP OS MS Outlook 2007 on my old system on my Windows 7 MS Outlook 2007 on my
-
Can receive but not send - Mail and Comcast Wiindows
I use Windows Mail and my email address is through Comcast. I get the fine on this laptop, but unable to send. I tried all the recommendations, but nothing works. This is the last error message I get: An unknown error has occurred. ' Subject 'test'