Sum according to the condition of another column
Hello
I develop a RTF to BI Publisher 11g, where the situation to make the amount based on the value in another column I
The sum of the column C amount what code = c
Total sum of D of the column amount what code = D
DATE CODE total
Apr - 13 C 234
Apr - 13 C 234
Apr - 13 C 234
Apr - 13 D 100
Apr - 13 D 100
Apr - 13 D 100
Total C 702
Total D 300
Please, let me know the formula or the workaround to achieve this.
Kind regards
Agnes
Need to see your xml structure to provide you with the exact code
Assuming that it is the structure:
After that you for each group pieces of code are the following: Total C: Total D: Thank you BipuserC
C
Tags: Business Intelligence
Similar Questions
-
How do rotate on a date and see the sum of the value of another column
Hello
I searched through the forum and cannot find a query similar to my question feels so post this new thread.
First of all, it is probably useful indicating that I am using Oracle 10 g.
I have a table that is used to store the details of the booking (essentially a booking system) and I would use this data to display the details of the customers stay on one line.
The table has the following columns:
Some example records could be:BOOKING_ID CUSTOMER_ID DATE_OF_ARRIVAL NUMBER_OF_NIGHTS NUMBER_OF_PEOPLE
On this basis I would like to display the output so that I can show a sum of the NUMBER_OF_PEOPLE reserved to per customer per day, as such:BOOKING_ID CUSTOMER_ID DATE_OF_ARRIVAL NUMBER_OF_NIGHTS NUMBER_OF_PEOPLE -------------------------------------------------------------------------------------------- 1 201 13-JAN-2010 5 1 2 202 13-JAN-2010 3 2 3 202 13-JAN-2010 4 1 4 203 15-JAN-2010 2 3
I watched analytical functions in the documentation and several books of Oracle that I have, but have so far struggled to find how to make the performance desired. Even using the excellent response to the previous post on the forum, I got I was not able to get a feasible request.CUSTOMER_ID 13-JAN 14-JAN 15-JAN 16-JAN 17-JAN 18-JAN 19-JAN ----------------------------------------------------------------------------------------- 201 1 1 1 1 1 0 0 202 3 3 3 1 0 0 0 203 0 0 3 3 0 0 0
Any help or advice would be much appreciated.
Kind regards
Stu
Published by: macmanxie on January 10, 2011 21:16Hello
macmanxie wrote:
... The suggested approach goes only to return a number if the DATE_OF_ARRIVAL corresponds to the date in the CASE statement, however I have the added complexity of wanting to show a count of all the days that the customer is booked, for, by making use of the NUMBER_OF_NIGHTS. I tried to use some of the examples provided on morganslibrary.org, for example:sum( CASE WHEN TRUNC (arrival_date) between '01/13/2011' and TRUNC (arrival_date+no_of_nights) THEN nvl(no_of_people,0) ELSE 0 END) AS jan_13
but this does not produce the desired result.
You check if arrival_date is between January 13 and arrival_date + no_of_nights (as if the arrival date could all be posterior to the arrival_date + no_of_nights).
Are not really interested in whether or not January 13 ib between arrival_date and arrival_date + no_of_nights?NVL ( SUM ( CASE WHEN TO_DATE ( '01/13/2011' , 'MM/DD/YYYY' ) BETWEEN TRUNC (arrival_date) AND TRUNC (arrival_date) + no_of_nights THEN no_of_people END ) , 0 ) AS jan_13
Always format your code. It is important to format your code if you are the only who who will ever read but it is even more important if you are posting on a forum like this and ask other people to read.
Not to compare the DATEs in the strings; explicitly use a conversion function, like TO_DATE, above, where necessary.
Both
SUM (NVL (x, 0)) and
NVL (SUM (x), 0) get the same results, but the latter is more effective. If you have 1000 lines, the first way is calling NVL 1000 times, but the second way is calling only once.If your previous thread
Re: How to count the occurrence of a date in a range
Gets you the right data, but it has one row for each distinct combination of customer_id and date, then you can switch it to a form that contains a line by the customer and another column for each date.If you need help, post CREATE TABLE and INSERT statements for some examples of data and outcomes from these data. The post you are trying better to a request, including a subquery that gets no cross-the raw table dynamic results.
There will be a fixed number of columns in the output swing? If this is not the case, how do you deal with that? Which of these options in the thread I posted above)
Re: County report and the sum of the number of rows by multiple columns
) is best for your needs? Than others is acceptable? -
Hello world
The task seems simple enough, but I have not found a way to populate an attribute transitional according to the value of another attribute when the line is queried. What is the best way to achieve this?
Thank you.
James
Use VORowImpl, if you have any transient attributes defined in the view object, whose value is derived from other attributes of the line, you can override the GET
method and add logic there Please note that this class represents a row in the results collection in a display object.
-
Editing a text field in aform according to the conditions
Hello
We develop a custom form that has a rematch of the database.
This form is a form master detail. He has a field called 'State' whose initial value is "Draft" and this field is present in the main part of the form.
The logic of "Draft" is written in trigger for insertion before the header block.
---------------------
Question
---------------------
If the condition 'A' and 'B' is met, the status must be defined as a value called as 'sent ';
If the condition is not satisfied and B is filled, status must be defined as a value called "Created";
We do this in the trigger of subsequent update to the block level. But the changes do not take effect.
Please let us know if this is the right approach for manage column. Note that the "Status" column is a column of data.
Thanks and greetings
SRHI SR,
948611 wrote:
HelloThanks for your reply.
I would remind the requirement:
There are 3 statuses - project--> this-> created.During the initial creation of registration, it is in the planning stage.
When this record is questioned in return and if a certain set of conditions is completed at the moment the State should change project to submitted project created or submitted.
We reach the features above, by creating a timer in the post REQUEST trigger BLOCK-level.
________________________________________
Create_timer ('ABC', 1000, no_repeat);
________________________________________In WHEN_TIMER_EXPIRED relaxation at the level of the FORM, we require a program unit that has the logic below:
We are looking for a certain set of conditions and modify accordingly the status as:
If condition A is true: block.status = project;
If condition B: block.status = subject;
If the condition C: block.status = crΘΘ;After that this COMMIT_FORM is published.
So your main point works well. ;)
Whenever the State gets past submitted or created, needs form to gray out which means that the user should not able to change the shape at this point.
For this, we use in the trigger after REQUEST of the BUILDING, the following:set_block_property ("BLOCK_NAME", insert_allowed, property_false)
set_block_property ("BLOCK_NAME", update_allowed, property_false)The code above works?
There will be a situation when the record that we ask for a status as an Envoy and the creation condition is met. In this case, the State should get passed to creation of subject. But somehow, it is not updated.
Please provide information on the implementation of this requirement.
What done you for this and where?
Hamid
Mark correct/good to help others to get the right answers. *
-
Necessary to valuate the sequence in another column in oracle
Hi all
I have the sql like query below
Select header_id, order_number of oe_order_headers_all.
and that's how the display of the data
heder_id order_number
111 500001
121 500400
I need to display a different field with values of sequence like as below
ID heder_id order_number
1 111 500001
2 121 500400
so, how to get the sequence value in another column help me please on this.
Thnaks
You can use virtual ROWNUM
Select rownum, header_id, order_number of oe_order_headers_all id
-
Add column if the value in another column
How can I add a column as column name 'YES_OR_NO.
SELECT VALUE_ID IN THE TABLE TABLE_NAME
VALUE_ID
---
1
2
3
4
5
Now, I want to create another column in the sql query called YES_OR_NO and that if there is a value in VALUE_ID then column YES_OR_NO must say 'YES' if there is no value in the column VALUE_ID of this line YES_OR_NO must say 'NO '.
or just a way for her also to work would be to show this new column or not if a value in another column of table_name_2 (this would be ideal)
If new column yes_or_no and fill by a Yes or a no if a value is found in another tableAssuming that you are on a version that supports the CASE expression:
SELECT VALUE_ID , case when VALUE_ID is null then 'NO' else 'YES' end as YES_NO FROM TABLE_NAME
-
Update the field Date according to the date of another field
Hi I have a field called "contract end Date" which I update manually according to the contract, and a field called "notify contract end Date" I want to be updated automatically with the "end of contract date" - 45 days.
Is this possible via workflow? can someone give me the syntax that works? If I want to manually insert the value of the field 'Date to end the contract to notify' it will overwrite it?
Thank you, DavidHello!
Create your workflow on your object type, select the before saving the trigger modification event, put the following condition:
[< contract end date >] <>MEADOW ("< the contract end date > '")
And in action, update the field End Date of the contract to notify with end Date of contract - 45 and check the replacement value. You contract end Date field must be with the type date.
I hope this will help, do not hesitate to ask for more!
Max
-
generate the value of the column according to the conditions
statement to generate the selection inputsBANNER Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for HPUX: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
entryWITH t AS ( SELECT 1 job_request_id, 1 original_job_request_id, mod(level,3) +1 sequence_cd, CHR (LEVEL + 100) value_txt, NULL new_sequence_cd FROM DUAL CONNECT BY LEVEL < 6), t1 AS ( SELECT 2 job_request_id, 1 original_job_request_id, mod(LEVEL,2) + 1 sequence_cd, CHR (LEVEL + 110) value_txt, NULL FROM DUAL CONNECT BY LEVEL < 10), t2 AS ( SELECT 3 job_request_id, 3 original_job_request_id, mod(LEVEL,3) + 7 sequence_cd, CHR (LEVEL + 95) value_txt, NULL FROM DUAL CONNECT BY LEVEL < 9), t3 AS ( SELECT 4 job_request_id, 3 original_job_request_id, mod(LEVEL,2) + 1 sequence_cd, CHR (LEVEL + 95) value_txt, NULL FROM DUAL CONNECT BY LEVEL < 7), t4 AS ( SELECT 7 job_request_id, 3 original_job_request_id, mod(LEVEL,2) + 1 sequence_cd, CHR (LEVEL + 92) value_txt, NULL FROM DUAL CONNECT BY LEVEL < 4), mytable AS (SELECT * FROM t UNION ALL SELECT * FROM t1 UNION ALL SELECT * FROM t2 UNION ALL SELECT * FROM t3 UNION ALL SELECT * FROM t4) SELECT * FROM mytable order by job_request_id, original_job_request_id, sequence_cd;
expected resultsJOB_REQUEST_ID ORIGINAL_JOB_REQUEST_ID SEQUENCE_CD VALUE_TXT NEW_SEQUENCE_CD 1 1 1 g 1 1 2 h 1 1 2 e 1 1 3 i 1 1 3 f 2 1 1 v 2 1 1 p 2 1 1 r 2 1 1 t 2 1 2 u 2 1 2 q 2 1 2 o 2 1 2 s 2 1 2 w 3 3 7 b 3 3 7 e 3 3 8 ` 3 3 8 f 3 3 8 c 3 3 9 d 3 3 9 a 3 3 9 g 4 3 1 e 4 3 1 c 4 3 1 a 4 3 2 b 4 3 2 ` 4 3 2 d 7 3 1 ^ 7 3 2 ] 7 3 2 _
my attempt to explain.JOB_REQUEST_ID ORIGINAL_JOB_REQUEST_ID SEQUENCE_CD VALUE_TXT NEW_SEQUENCE_CD 1 1 1 g 1 1 1 2 h 2 1 1 2 e 2 1 1 3 i 3 1 1 3 f 3 2 1 1 v 4 2 1 1 p 4 2 1 1 r 4 2 1 1 t 4 2 1 2 u 5 2 1 2 q 5 2 1 2 o 5 2 1 2 s 5 2 1 2 w 5 3 3 7 b 7 3 3 7 e 7 3 3 8 ` 8 3 3 8 f 8 3 3 8 c 8 3 3 9 d 9 3 3 9 a 9 3 3 9 g 9 4 3 1 e 10 4 3 1 c 10 4 3 1 a 10 4 3 2 b 11 4 3 2 ` 11 4 3 2 d 11 7 3 1 ^ 12 7 3 2 ] 13 7 3 2 _ 13
If the job request id = id of the new cd of sequence = sequence cd original job application
When the employment application IDS are higher than the original increment the new cd of sequence with respect to the maximum of the original work request id sequence cd.
I hope that the expected results will clarify.Hello
It looks like you want DENSE_RANK, except that you want to ignore the numbers (for example, 6 in this example) when necessary so that new_sequence_cd > = sequence_cd.
With the help of analytical functions:
WITH got_drank AS ( SELECT m.* , DENSE_RANK () OVER ( ORDER BY job_request_id , original_job_request_id , sequence_cd ) AS drank FROM mytable m ) SELECT job_request_id , original_job_request_id , sequence_cd , value_txt , drank + MAX ( sequence_cd - drank ) OVER ( ORDER BY job_request_id , original_job_request_id , sequence_cd ) AS new_sequence_cd FROM got_drank ORDER BY job_request_id , original_job_request_id , sequence_cd ;
You can also use the MODEL.
If you have a new_sequence_cd column in a table, one you want to fill, use the query in a MERGE statement above.
-
Change column bg-color according to the values in this column.
Version of the apex is 4.2.4
To keep it short, I want the background of one of my field to be red when it is NULL, when there are data in it, I want it to be green.
The first is what it looks currently, second photo, that's how I want it to look!
Option
Use the column layout features.
It is a bit of a hack, but it works well.
1. Add a column to your query that contains the logic for your choice of color.
decode (department_id, 30, 'BLUE', 'RED') AS DEPT_COLOR
2 - cut the column in the report properties - so it does not appear.
3 - update the column in question-> column-> Expression HTML formatting
Add the desired HTML logic.
Ex:
#DEPARTMENT_ID #.Now it works OK for some styles and formatting - but the DIV in a table cell is kind of a weird look.
Option
Create a report model that put this condition of the column in place. To create a column a different color, you will need to use a level line model.
Option
Put in a bit of jQuery with option 1.
-Create a class that you can button
#DEPARTMENT_ID #.
-Create a region on the bottom of the page
$(".find_me_RED").parent().css("background-color","RED");
$(".find_me_BLUE").parent().css("background-color","BLUE");
Note: This will not work if you are using one of the reports that have the '' mouse highlighting. ''
-
How to TOGGLE OFA form field according to the conditions
Dear all,
I'm new to OAF and started learning the OFA.
I have a requirement as below,
The Window(OAF Page) provider, there is a tab named 'key to purchase Setups '.
Here if the provider's site is already created and 'Pay' and "Level summary invoice" columns is to have values, questioning the site begging, I want to disable (not editable) the two fields 'Invoice Summary Level' and 'Pay' for all users except IE a user Guru
Using customization, I can put the READ ONLY option, but I need to be implemented for the above condition.
Can anyone suggest me how to proceed?
Thank you
Kind regards
Guru
Hello.
I think that your condition is the same as it
Dynamically set read-only columns in the tabular presentation at record levels
I already mentioned solution.
Same would apply to you.
-
Interactive report, change in color of the text based on the value in another column
I have a sample report at this url:
workspace: homeworld
username: test_report
password: test_report
APEX version 4.2.3 database 11 g release 2...
# Application: 202: IR TEST REPORTS
Page in question is #2 page
I have the setup of the report and you must make the following change...
I have 2 columns: Comm and bonus.
If the bonus > comm, I need to change the text color of the color of the Red bonus
If the bonus, comm, I need to change the text color of the bonus in green color
If the bonus = comm, I need to change the text color of the bonus to black color
I tried using the code with the select and am NOT wanting that, since he will be delivered with the data when they are downloaded in CSV or Excel... Had thought using the construction by highlighting, but that does not compare one column to another...
Thought a dynamic action, but not clear on HOW to do this, so any help would be appreciated...
Thank you
Tony Miller
Software LuvMuffin
Hello
I think that number with JavaScript conversion may not be good idea because it's difficult manipulating different digital formats.
Check your example on page 3.
I have added to the report query
CASE WHEN COALESCE(bonus,0) > COALESCE(comm,0) THEN 'red' WHEN COALESCE(bonus,0) < COALESCE(comm,0) THEN 'green' WHEN COALESCE(bonus,0) = COALESCE(comm,0) THEN '#333333' END as fcolor
Then I modify every column Expression HTML to be as
#EMPNO#
Kind regards
Jari -
How can I delete pages in a 3D table, based on the conditions in two columns
Given the enclosed 3D range I would delete any page that has BOTH 3 900002 chain in the second column AND the string "00 00 00 00 00 00 00 00" in column 5. Any ideas on how to do this?
Thank you.
-
Search for a similar string in the 2D array and displays the result with another column
Hello
One who can help, I have a chart 2D of txt file that have as many lines and 5 columns and I want to do a search and display the other results of the column.
For example.
Column 0 1 2 3 4
12345 qwer asdf 12qwe tjhrtyert
werr 23568 wef fgertge fsefff
If I manage to find 12345 and I want to display 12qwe, what should I do in labview? Help, please!
-
How to change the filter to the filter by another column - group calendar page 1
Any version of the Summit either 4.2 or 5.0 - windows 7 OS
I know it's a very simple question, but I can't understand this.
I want to change the filter on the group calendar page 1 of the default "Event status" below
The only code that I find is shown below.
I added my own selection list of the button with the following code bar
< tt > Select GroupName, group_id from EBA_CA_EMAIL_GROUPS ORDER BY GroupName < /tt >
But when I change the selection list from one option to the other that the calendar is not sorted by events that have particular GroupName. I tried to replace the code in the default selection list and it did not work. There must be another code, check the filter.
How can I add my own list of selection and filter calendar events based on that select list option is selected?
Richie V wrote:
Any version of the Summit either 4.2 or 5.0 - windows 7 OS
I know it's a very simple question, but I can't understand this.
I want to change the filter on the group calendar page 1 of the default "Event status" below
I added my own selection list of the button with the following code bar
Select GroupName, group_id from EBA_CA_EMAIL_GROUPS ORDER BY GroupName
But when I change the selection list from one option to the other that the calendar is not sorted by events that have particular GroupName.
Probably you meant 'filtered' rather than 'sort '?
I tried to replace the code in the default selection list and it did not work. There must be another code, check the filter.
In the Group APEX 5.0 calendar application, the filter is implemented in line 20 of the schedule area source query:
select e.event_id, case when et.display_color is not null then 'apex-cal-'|| (select lower(cp.color_name) from eba_ca_color_prefs cp where cp.bg_color = et.display_color) end css_class, e.event_name, case when e.display_time = 'N' then trunc(e.event_date_time) else e.event_date_time end event_date_time, to_char(e.event_date_time,v('APP_TIME_FORMAT')) disp_time, substr ( case when to_char(e.event_date_time,'MI') = '00' then ltrim(to_char(e.event_date_time,'HHam'),'0') else ltrim(to_char(e.event_date_time,'HH:MIam'),'0') end|| ' '||e.event_name,1,255) disp_col from EBA_ca_events e, EBA_ca_event_types et where (:P1_EVENT_TYPE = e.type_id or :P1_EVENT_TYPE is null) and e.type_id = et.type_id (+)
with P1_EVENT_TYPE being included in the property of the region and by using the action Elements of the Page to send dynamic update schedule to trigger a refresh of partial page in the calendar area.
How can I add my own list of selection and filter calendar events based on that select list option is selected?
1 create your filter as a copy the item P1_EVENT_TYPE item.
2. replace the LOV definition by the code you need.
3. Add the necessary filter predicate in the WHERE clause of the query source region.
4. Add the name of your filter element to the region of the Items property of the Page to send.
5. Add the name of your item to the Items property in the when section of action Dynamics to update the calendar .
-
Layer of scale automatically according to the proximity of another layer
Hello!
I am trying to write an expression that will scale a layer down as another layer gets closer (simulating a UI jumping off the page as a the mouse cursor is on it). That's what I have so far (a term applied to the scale property of the target layer):
x = Math.abs ((effect ('Mouse Layer') (1)).transform.position [0] - transform.position [0]); distance from the target layer and the mouse on the x-axis
y = Math.abs ((effect ('Mouse Layer') (1)).transform.position [1] - transform.position [1]); distance between the target layer and right-click the axis y
t = Math.sqrt ((Math.pow (x, 2)) + (Math.pow(y,2))); the actual distance of mouse layer in the center of the target layer
fadeDist = effect ("Fade Dist") (1); distance to which layer begins the scaling
sMin = ("sMin") effect (1); minimum scale
sMax = ("sMax") effect (1); full scale
s ease = (t, 0, fadeDist, sMax, sMin);
[s,];
It works fairly well, but it is based on the distance between the Center of the target layer and the mouse, not the limits/edges of it. For this reason, scale the target layer becomes as the mouse moves around the area of the layer itself.
Is it possible for me to write this expression which 1) allow me to refer to the distance between the mouse and the edges of the target layer (a rectangle) the factor affecting the scale of the layer and 2) maintains the balance of the rectangle while the mouse moves that it contains?
Thank you!!
This is probably not exactly what you are looking for, but it may give you some ideas. It seems to work for a rectangular solid. It evolves as the mouse layer approaches, but remains at the top of the scale, once the mouse is inside the solid:
sMax = 150; Max scale
sMin = 50; scale min
dMax = 100; When the scale starts to distance
dMin = 0; When the scaling of the remote ends
M = thisComp.layer ("Layer mouse");
PM = M.toComp (M.anchorPoint);
x = h [0];
y = h [1];
p = toComp (anchorPoint);
xMin = p [0] - width * sMax/200;
xMax = p [0] + width * sMax/200;
yMin = p [1] - height * sMax/200;
yMax = p [1] + height * sMax/200;
If (x<>
If (y<>
d = length (pm, [xMin, yMin]);
} ElseIf (y<>
d = xMin - MP [0];
} else {}
d = length (pm, [xMin, yMax]);
}
} ElseIf (x<>
If (y<>
d = yMin - MP [1];
} ElseIf (y<>
d = dMin;
} else {}
d = h [1] - yMax;
}
} else {}
If (y<>
d = length (pm, [xMax, yMin]);
} ElseIf (y<>
d = h [0] - xMax;
} else {}
d = length (pm, [xMax, yMax]);
}
}
s = linear (d, dMin, dMax, sMax, sMin);
[s]
Dan
Maybe you are looking for
-
I just can't get anything to install on my new apple tv. I click the button install for netflix for example and nothing happens
-
I bought 6 s 2 weeks ago. I found my 6s signal strength is less than 6 s of my friends, with the same telco provider. We put our phone next door. And my 6s has shown more low-power signal compared to theirs. Can I know how to check? Or is my issue 6s
-
Fluctuating audio when you use internet in Pavilion N-012TX
In usinf HP Pavilion N-012TX (windows 8) A these days, whenever I try to listen to music while surfing on internet, the audio starts fluctuating and him no matter what browser I use fluctuates during the loading of any page. I did not any changes to
-
Apple music: synchronization between the MacBook and the iPhone
Hello I have the problem that I have the musics of the apple iPhone and MacBook. I use the same account here and here, but my list of music not sync between devices. Early on worked, but I changed the region and still later once I changed and I lost
-
Vista Premium System Restore does not work
Bought a Toshiba laptop Satelite (L505D-S5965, processor AMD Athlon Dual-Core QL-65, 3 GB SDRAM, 250 GB HDD) with Vista Home Premium. I have 195 GB of free space. Everything works well except the system restore. Impossible to restore using the res