How the sum of these two tables?
Hello
I have two tables
DESC ACTIVITE_EXCEP_FAITE
NUMBER OF FICHE_ID
NUMBER OF SERVICES_ID
NUMBER OF ACTIVITES_EXCEPTIONNELLES_ID
NUMBER OF TIME
NUMBER OF ACTIVITE_EXCEP_FAITE_ID
DESC ACTIVITE_FAITE
NUMBER OF FICHE_ID
NUMBER OF ACTIVITES_ID
NUMBER OF SECTEURS_ID
LENGTH NUMBER (8.2)
NUMBER OF ACTIVITE_FAITE_ID
NUMBER OF TYPE_ACTIVITE_ID
I want to add the column to the DURATION of the two tables when they get the same FICHE_ID. FICHE_ID is not a join field.
I've tried this application, but it gives result when two recordings of the two table share the same number FICHE_ID.
SELECT AF. FICHE_ID, SUM (NVL (AF. LENGTH, 0)) + SUM (NVL (AEF. LENGTH, 0))
OF AF, ACTIVITE_EXCEP_FAITE AEF ACTIVITE_FAITE
WHERE AF. FICHE_ID = AEF. FICHE_ID
GROUP BY AF. FICHE_ID;
Can you help me write this selection?
Thank you very much for your help!
Like this?
select nvl(af.fiche_id, aef.fiche_id) fiche_id , sum(nvl(af.duree,0)) + sum(nvl(aef.duree,0)) duree from activite_faite af full join activite_excep_faite aef on af.fiche_id = aef.fiche_id group by nvl(af.fiche_id, aef.fiche_id);
Tags: Database
Similar Questions
-
How to match columns from two tables with
Hello:
I have two tables as below:
Table1::(Base Table)
Country | Prefix | Prefix_Length
Travel | 001 | 3
CountryB. 0012 | 4
PaysC | 00443 | 5
CountryD | 0091 | 4
:(Detail Table) table2
The population | Area | Prefix
500 | AreaA | 0015921
1000 | AreaB | 00122
400. AreaC. 00443743
300. ALIS | 0091333
100. AreaA | 001
I need to match these two tables with prefix columns (whose length is not fixed in the two tables: but it starts with 00 in the two tables). Two different countries the prefix may be similar up to a certain length. Thus, Prefix_Length can be used to determine (exactly) how much time should be taken in the search of Table2.
Output:
Country | Prefix | Area | Population
Travel | 001 | AreaA | 600
CountryB. 0012 | AreaB | 1000
PaysC | 00443 | AreaC. 400
CountryD | 0091 | ALIS | 300
Please help me with your valuable comments.
-TenderTry this
with base_table as ( select 'CountryA' country,'001' prefix,3 prefix_length from dual union all select 'CountryB','0012',4 from dual union all select 'CountryC','00443',5 from dual union all select 'CountryD','0091',4 from dual ), detail_table as ( select 10 no_of_call,'0015921' prefix from dual union all select 3,'00122' from dual union all select 50,'00443743' from dual union all select 50,'00443643' from dual union all select 300,'0091333' from dual union all select 60,'001' from dual ) SELECT country, prefix,sum(no_of_call) FROM ( select country, b.prefix,no_of_call, decode(no_of_call,lead(no_of_call,1,0) over(partition by no_of_call order by b.prefix,no_of_call),'y','n') y_or_no from base_table b, detail_table d where b.prefix = substr(d.prefix,1,prefix_length)) where y_or_no !='y' group by country, prefix order by country, prefix;
Published by: Vi on 20 February 2012 01:07
-
How the SUM cells including the text and the number?
Hello world
Someone can tell me how the SUM cells include the text and the number?
1 Bob 20
2 30 Jane
3 50 Jame
Total 100
Thank you
Hi Jordan,.
If the numbers are not always two digits, FIND the position of the space between the number and name:
Formula in B2 (fill down)
= FIND("",A2)
Then use the LEFT function to get the number in the column C:
Formula in C2 (fill down)
= LEFT (A2, B2)
This will give a text string (Tip: left-aligned).
Convert to a numeric value in the D column with the VALUE function:
Formula in D2 (fill down)
VALUE = (C2)
(Tip: propped right)
Table 1 has a header row and footer of the line, and the SUM is easy. Formula to the D8 footer line:
= SUM (D)
Kind regards
Ian.
Edit: You can hide columns B and C
Ian.
-
I have two e-mail accounts, each has two licenses, how can I have these two licenses only by email?
Since this is an open forum, not Adobe support... you must contact Adobe personnel to help
Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">===>
Don't forget to stay signed with your Adobe ID before accessing the link below
Creative cloud support (all creative cloud customer service problems)
-
What is the difference between these two triggers.
Hi guys,.
Can you please the difference between these two triggers:
A
VSCREATE OR REPLACE TRIGGER "T_CLIENT_STATUS_LOOKUP" before insert or update on "CLIENT_STATUS_LOOKUP" for each row begin if inserting and :new."CLIENT_STATUS_ID" is null then for c1 in (select "CLIENT_STATUS_LOOKUP_SEQ".nextval nv from dual) loop :new."CLIENT_STATUS_ID" := c1.nv; end loop; end if; end;
B
I created manually trigger B. But to trigger A, on APEX, we have created by APEX lookup table. Then, I got a relaxing by APEX. but I did not understand the difference.CREATE OR REPLACE TRIGGER "CLIENTS_TRG1" BEFORE INSERT ON ERP.CLIENTS FOR EACH ROW begin if :new.CLIENT_ID is null then select CLIENTS_seq.nextval into :new.CLIENT_ID from dual; end if; end;
Kind regards
FatehMy vote 2nd relaxation. Because in the first trigger you use ' before insert or update", but there is nothing so far...; Oracle must go in the PL/SQL engine for each update to the table without reason; There is nothing to update, you do not have to shoot. While in the 2nd you do something sensible; If client_id is null, it will go to search by sequence forward.
Concerning
Girish SharmaPublished by: Girish Sharma on June 9, 2012 13:06
Just paste your code into the code for easy reading tags:CREATE OR REPLACE TRIGGER "T_CLIENT_STATUS_LOOKUP" before insert or update on "CLIENT_STATUS_LOOKUP" for each row begin if inserting and :new."CLIENT_STATUS_ID" is null then for c1 in (select "CLIENT_STATUS_LOOKUP_SEQ".nextval nv from dual) loop :new."CLIENT_STATUS_ID" := c1.nv; end loop; end if; end; CREATE OR REPLACE TRIGGER "CLIENTS_TRG1" BEFORE INSERT ON ERP.CLIENTS FOR EACH ROW begin if :new.CLIENT_ID is null then select CLIENTS_seq.nextval into :new.CLIENT_ID from dual; end if; end;
-
What is the difference between these two JKM and when to use that one.
Please tell the difference between these two.
JKM Oracle compatible o JKM Oracle compatible (Date of update)Basic difference is in the obligation.
JKM Oracle compatible (Date of update) wants a DATE/TIMESTAMP column in the source tables (s) who will get inserted/updated updated by the source application. ODI will capture the data modified, based on the value of this column. Only the DELETION part requires a trigger to keep track of deletion happening at source one or more tables.
Where as JKM uniform Oracle does not require any which TIMESTAMP column in the tables of the source (s). It uses triggers to keep track of the INSERT/UPDATE/DELETE happening in the source.
Compatible JKM Oracle performance (Update Date) is preferable, because it will create a little over the head on your source system. SO if you have a DATE/TIMESTAMP column in the tables of the source (s) that gets inserted/updated by the source application, then go JKM Oracle compatible (Date of update).
Otherwise search JKM consistent Oracle.
Thank you
Fati -
What is the difference between these two series: ONE VIDEO and a VIDEO SN184?
Hello
Is anyone know the difference between these two serial numbers: A VIDEO and a VIDEO SN184?
Hi Lennart,
This might be useful: ONE VIDEO AND ONE NON-VIDEO
Kind regards
Sheena
-
What is the relationship of these two methods
What is the relationship of these two methods: Manage consistency using JMX and consistency to manage using the brand manager (Grid Control)?
Supplementary, substitute or mutualists?
Can they be used together?
What to feel, to use them to manage consistency?
Thank youEnterprise Manager is constructed using the Foundation of consistency JMX. If the grid should be configured for the remote for the company nursery management work.
Thank you
Everett Williams
Team coherence -
How to remove the extra space between two Table HTML
Hello
I wrote a code for printing costs. But there is more space between two Table Html, how I can remove it.
Please run that Code
Start
HTP.p (')
< html >
(< body > ');
HTP.p (')
< TABLE align = "left" width = "500" cellspacing = "0" cellpadding = "0" border = "1" >
< tr > < td align = 'right' white-space: nowrap; > Ph-2201751 < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > < B > < table > < /B > SATYAM MODERN PUBLIC SCHOOL
< td > < table >
< /tr >
< b >
< td align = "center" white-space: nowrap; > < i > < H3 > (AFFILIATED to THE CBSC, NEW DELHI CODE No. 53544) < / H3 > < /I > < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > new colony Braham, - 131001 (h) < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > RECEPTION COSTS < table >
< td > < table >
< /tr >
< /table >
< TABLE width = "500" cellspacing = "0" cellpadding = "0" border = "1" >
< b >
< td width = "100" white-space: nowrap; > receipt no.: < table >
< td width = "100" white-space: nowrap; > Date received: < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > name: < table >
< td width = "100" white-space: nowrap; > father name: < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > class & s: < table >
< td width = "100" white-space: nowrap; > A/C No. : < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > from: < table >
< td width = "100" white-space: nowrap; > to: < table >
< /tr >
(< /table > ');
HTP.p (')
< / body >
(< / html > ');
end;
Thank you
EdHello
HTML is valid, that your code print?
Wouldn't be as below?
BR, Jari
Published by: jarola on December 18, 2009 15:22
I test your code
http://Apex.Oracle.com/pls/OTN/f?p=40323:25
I can't see any extra space between the tablesHow to update these two tables
Hello
I have two tables (in Oracle 11 g R2) and need to lock some lines in each of them for the update...
Here is the sample data and the result after update, please help me for update instructions.
Thanks in advance!
drop table t1; drop table t2; create table t1( t1_id number(5) primary key, t1_col2 varchar2(20), t1_col3 varchar2(10), t2_id varchar2(5)); create table t2( t2_id varchar2(5) primary key, t2_col2 varchar2(10), t2_col3 number(2), t1_id number); insert into t1 values(1, '1 - col2', 'AB', null); insert into t1 values(2, '2 - col2', 'AB', null); insert into t1 values(3, '3 - col2', 'AB', null); insert into t1 values(4, '4 - col2', 'AC', null); insert into t1 values(5, '5 - col2', 'AC', null); insert into t1 values(6, '6 - col2', 'AC', null); insert into t1 values(7, '7 - col2', 'AC', null); insert into t1 values(8, '8 - col2', 'AC', null); insert into t1 values(9, '9 - col2', 'AC', null); insert into t1 values(10, '10 - col2', 'AC', null); commit; insert into t2 values('11001', 'ABC', 12, null); insert into t2 values('11021', 'ABC', 12, null); insert into t2 values('11022', 'ABC', 12, null); insert into t2 values('11023', 'ABC', 12, null); insert into t2 values('11024', 'ABC', 12, null); insert into t2 values('11025', 'ABC', 12, null); insert into t2 values('11030', 'ABC', 12, null); insert into t2 values('11035', 'ABC', 12, null); insert into t2 values('11051', 'ABC', 12, null); insert into t2 values('11061', 'ABC', 12, null); insert into t2 values('11071', 'ABC', 12, null); insert into t2 values('11081', 'ABC', 11, null); insert into t2 values('11091', 'ABC', 11, null); commit; declare cursor c1 is select * from t1 where t1_id in(select t1_id from (select t1_id from t1 where t1_col3 = 'AC' order by t1_id) where rownum <= 5) for update; cursor c2 is select * from t2 where t2_id in(select t2_id from (select t2_id from t2 where t2_col3 = 12 order by t2_id) where rownum <= 5) for update; begin for rec_c1 in c1 loop ??? end loop; end; / The result must look like: T1_ID T1_COL2 T1_COL3 T2_ID ---------- -------------------- ---------- ----- 4 4 - col2 AC 11001 5 5 - col2 AC 11021 6 6 - col2 AC 11022 7 7 - col2 AC 11023 8 8 - col2 AC 11024 T2_ID T2_COL2 T2_COL3 T1_ID ----- ---------- ---------- ---------- 11001 ABC 12 4 11021 ABC 12 5 11022 ABC 12 6 11023 ABC 12 7 11024 ABC 12 8
With the help of Bencol :-)
DECLARE CURSOR c1 IS SELECT a.t1_id, b.t2_id FROM t1 a CROSS JOIN t2 b WHERE (a.t1_id, b.t2_id) IN (SELECT t1.t1_id, t2.t2_id FROM (SELECT t1_id , ROW_NUMBER () OVER (ORDER BY t1_id) t1_rn FROM t1 WHERE t1_col3 = 'AC') t1 JOIN (SELECT t2_id , ROW_NUMBER () OVER (ORDER BY t1_id) t2_rn FROM t2 WHERE t2_col3 = 12) t2 ON t1.t1_rn = t2.t2_rn WHERE t1.t1_rn <= 5) FOR UPDATE; BEGIN FOR rec_c1 IN c1 LOOP UPDATE t1 SET t2_id = rec_c1.t2_id WHERE t1_id = rec_c1.t1_id; UPDATE t2 SET t1_id = rec_c1.t1_id WHERE t2_id = rec_c1.t2_id; END LOOP; END; /
Kind regards.
Alexport the schema, but for two tables, export only 20 rows
11.2.0.2/RHEL 5.4
Using expdp, I want to export an entire schema. But for the 2 large tables (say the EMP and DEPT tables) in this diagram, I want to export only 20 records (at random) for them. Is it possible for expdp and impdp?
If this is not possible then, is there any option to have no any line for these 2 tables?Christian Christmas Pal Singh says:
possible, but you must create two files dmp means export of run 2 times.
1. for complete schema to exclude these 2 tables by the exclusion clause.
2. use the query clause to filter the data in the second export for these 2 tables.Really? is not something that similar work? instead of rownum, if you want truly random, then use example of clause, but it should be based on the amount of sample would make 20 lines for you, then a bit of work there.
schemas=my_schema QUERY=my_schema.table1:"where rownum < 21" QUERY=my_schema.table3:"where rownum < 21"
Published by: rjamya on Sep 19, 2012 08:32
How graphic how the sum of several metrics of in a dashboard.
I'm looking to find out how the graph of the sum of multiples of the metric, as CPU ready, or latency of disk in one graph on a dashboard / report.
An example would be showing collective management s VM in balloning of CPU and memory of the pool on line on a chart.
Thank you!
If you want the chart to reflect everything that you can do the stacking graphics option which will be sleeping all values.
How the sum of a series of if Athens?
Given:
I need adding the cost of reception (PM01) breakfast (Cost01), reception cost (Cost02) and lunch cost of reception (Cost03).
If the cost of each receipt exceeds each meal allowance, use value meal in sum compensation.
If the cost of each reception is less than or equal to each value of the meal allowance, then use the cost of reception in all.
You can use a calculation script customized to the field which displays the sum, something like:
Custom calculation script
(function () {}
Get the field values as numbers
var v1 = + getField("Cost01").value;
var v2 = + getField("Cost02").value;
var v3 = + getField("Cost03").value;
Add the eligible amounts of breakfast, lunch and dinner
and set the value of this field
Event.Value = Math.min (v1, 12) + Math.min (v2, 17) + Math.min (v3, 27);
})();
I ran two computers and would like to be able to download Lr jobs made on my laptop, my PC fixed, also used to treat other images, all stored on the same disk.
In other words, I want to deal with may photos on both PC and have access to all analyses of one or even two computers better regardless.
Samek.
This was very helpful. Thank you very much
Samek
calculation of ratios and rounding - how the sum of last record to give 1
I'm putting in a single query to calculate the reports for an unknown number of records. I want to turn the ratios to 5 decimal places and I want the total reports of equal to 1.
for example
If I have 3 folders with Qty total overal 4,5,6 is 15
I note 3 lines
Round (4/15.5),
Round (5/15.5),
Round (6/15.5)
but I want to ensure total = 1
so I will try to do something like
Round (4/15.5),
Round (5/15.5),
1 - round(4/15,5) - round(5/15,5)
can someone help show me the sql construction? I've been trying and failing using where clause
of course this example would add to 1 but other unknown ratios may not match up to 1.
Published by: user12154024 on November 2, 2009 22:32Hello 12154024,
Welcome to the forum. May not be a more elegant solution, but it shows how it works step by step
WITH t AS ( SELECT 4 n FROM dual UNION ALL SELECT 5 n FROM dual UNION ALL SELECT 6 n FROM dual ) ,t1 AS ( SELECT n ,ROUND(RATIO_TO_REPORT(n) OVER (),5) AS rr ,COUNT(n) OVER () AS c ,ROW_NUMBER() OVER (ORDER BY n) AS rn FROM t ) ,t2 AS ( SELECT n ,rr ,SUM(rr) OVER (ORDER BY n) s ,c ,rn FROM t1 ) SELECT n ,rr ,CASE WHEN c = rn THEN rr + (1 - s) ELSE rr END rr2 ,s FROM t2 ORDER BY rn; N RR RR2 S --- --------- --------- -------- 4 0.26667 0.26667 0.26667 5 0.33333 0.33333 0.6 6 0.4 0.4 1 3 rows selected
The part "WITH t AS" generates data
T1 calculate the ratio, counts the number of records and signs a current issue
T2 to calculate a cumulative ratio
the last part takes these data and for the last record (number = count running) it allows to adjust the ratio.You can see if you are using other data
WITH t AS ( SELECT 4.78 n FROM dual UNION ALL SELECT 5 n FROM dual UNION ALL SELECT 6 n FROM dual ) ... N RR RR2 S ---- -------- -------- -------- 4.78 0.30292 0.30292 0.30292 5 0.31686 0.31686 0.61978 6 0.38023 0.38022 1.00001 3 rows selected
Concerning
MarcusMaybe you are looking for
-
Using Norton AntiVirus with the iMac
For years I used Norton AntiVirus on my iMac with no problems that I know. Recently, a novice iMac user was informed by a person from a person of type Geek Squad remove Norton AntiVirus from his Mac immediately because it destroys all of Apple secur
-
When I tried to access the site stationeryheaven.com , I have a white page with this error message. Error. Page cannot be displayed. For more details, please contact your service provider. (9)It has been long since I have been on this site, but why I
-
Ports of USB 3.0 EliteBook 8470p not recognize USB 3.0 devices
USB 3.0 ports 8470p EliteBook located on the left side of the PC (near the ms in) is not recognizing the USB 3.0 devices. Operating system is Windows XP Professional SP3 and the BIOS has been updated to the most recent available on HP website. Any su
-
How to save the value controls in labview
HelloI want to know how to record the value of controls in the PC. means if I attribute 5 numeric value to a control, he has to stay there even I restart my PC.
-
The HP Laserjet Pro 100 Color MFP 175nw scanning
Does anyone know if HP Laserjet Pro 100 Color MFP 175nw requires the Ethernet connection to scan documents or WiFi will be sufficient?