Results of the difference of two queries with a result zero
HelloI use a query, as shown in the following example:
SELECT the vault, id1 - id2, wf1 - wf2 tr1 - tr2 OF
(SELECT sc, SUM (id1), SUM (wf1), SUM (tr1) FROM table1 GROUP BY sc) a.,
(SELECT sc, SUM (id2), SUM (wf2), (tr2) SUM OF table2 GROUP BY sc) b
WHERE arch = BSC.
The results are good, but I have the problem if the baccalaureate is NULL that I get a result for the values. What I need, is that the result should show the vault and other values, if the degree is NULL.
As
SQL> select distinct deptno from emp
2 /
DEPTNO
----------
30
20
10
SQL> select deptno from dept
2 /
DEPTNO
----------
10
20
30
40
SQL> select
2 nvl(e.deptno, d.deptno) , nvl(e.c1,d.c1)
3 from
4 (select deptno, count(*) c1 from emp group by deptno ) e,
5 (select deptno, count(*) c1 from dept group by deptno ) d
6 where
7 e.deptno (+) = d.deptno
8 /
NVL(E.DEPTNO,D.DEPTNO) NVL(E.C1,D.C1)
---------------------- --------------
30 6
20 5
10 3
40 1
SQL>
Published by: s_2 on November 3, 2008 17:37
Tags: Database
Similar Questions
-
Help to combine the two queries with dependencies
Combining two queries with dependencies:First ask: Returns USER_ID that has a type of access to a table with the OWNER (I also shoot the TLA of the USER_ID standard: ' of TLA #)Select distinct SUBSTR (DBA_USERS. Username, 2, 3) AS TLA
DBA_USERS. Username USED_ID
DBA_TAB_PRIVS. Owner OWNER
from DBA_USERS
DBA_ROLE_PRIVS
DBA_TAB_PRIVS
where DBA_USERS. Username = DBA_ROLE_PRIVS. Dealer
and DBA_USERS.default_tablespace not in ('SYSTEM', "SYSAUX")
and DBA_USERS. Username like would be %'
and DBA_ROLE_PRIVS. Granted_role = DBA_TAB_PRIVS. Dealer
and SUBSTR (DBA_USERS. Username, 2, 3) <>DBA_TAB_PRIVS. Owner
;
Example of results (red font used in the last citation):TLA USED_ID OWNER
--- ------------------------------ ------------------------------
DGTX999 GTX GRR
DGTX999 GTX ABG
DGTX999 GTX HTC
FWS DFWS999 GRR
OCN DOCN999 GRR
RHR DRHR999 DAS
ETM DETM999 DAS
FWS DFWS995 DAS
CD DCDS999 DAS
ABE DABE999 DAS
Second request: matches the USER name (same standards as above) and MACHINES (filter PC connections) and the number of connections made ofSelect DBA_USERS. Username
DBA_HIST_ACTIVE_SESS_HISTORY. Machine
COUNT (*) AS CONN_COUNT
of DBA_HIST_ACTIVE_SESS_HISTORY
DBA_USERS
where DBA_HIST_ACTIVE_SESS_HISTORY. User_id = DBA_USERS. User_id
and DBA_USERS. Username like would be %'
and DBA_HIST_ACTIVE_SESS_HISTORY. Machine not as "WINAD%\%-%".
Group of DBA_USERS. Username
DBA_HIST_ACTIVE_SESS_HISTORY. Machine
order by 1
3 desc;
Example of results (red font used in the last citation):MACHINE CONN_COUNT USERNAME
--------------- ------------------------- ----------
DFWS999 home13e0 7557
DGAM800 vu1246 37
DGAM999 vu1246 2558
DABE999 back18cb 4639
DINL888 home162f 84
DFWS999 WINDAD\OMHQ58BF 178
DCDS999 back18cb 788
DGTX999 home18c8 7
DGTX999 home13d3 62
DOCN999 vu1261 44
DFWS999 back1976 3
DCDS999 home18c8 173
DGTX999 home19c9 13
What I'd like to have (just made two first USER_IDs from the first query) (COL duplicated for each separate owner 1-4). So 3 machines and 3 owners would result in 9 lines (I could reorganize the collar and use a 'pause'):
TLA USED_ID MACHINE CONN_COUNT OWNER
--- ------------------------------ ------------------------- ---------- ------------------------------
GTX DGTX999 home13d3 62 GRR
Home18c8 GTX DGTX999 7 GRR
DGTX999 GTX home19c9 GRR 6
GTX DGTX999 home13d3 62 ABG
DGTX999 GTX home18c8 ABG 7
DGTX999 GTX home19c9 6 GBS
GTX DGTX999 home13d3 62 CTH
DGTX999 GTX HTC 7 home18c8
DGTX999 GTX home19c9 6 HTC
FWS DFWS999 home13e0 7557 GRR
FWS DFWS999 WINDAD\OMHQ58BF 178 GRR
FWS DFWS999 back1976 GRR 3
So it would be logically read: TLA as USER_ID of MACHINE, CONN_COUNT consultation times: OWNER information.Thought as only those with the necessary values. Just try this and let me know in the case of all conflicts in the output.
WITH T1 AS)
Select distinct SUBSTR (DBA_USERS. Username, 2, 3) AS TLA
DBA_USERS. Username USED_ID
DBA_TAB_PRIVS. Owner OWNER
ROWNUM RN
from DBA_USERS
DBA_ROLE_PRIVS
DBA_TAB_PRIVS
where DBA_USERS. Username = DBA_ROLE_PRIVS. Dealer
and DBA_USERS.default_tablespace not in ('SYSTEM', "SYSAUX")
and DBA_USERS. Username like would be %'
and DBA_ROLE_PRIVS. Granted_role = DBA_TAB_PRIVS. Dealer
and SUBSTR (DBA_USERS. Username, 2, 3) <> DBA_TAB_PRIVS. Owner),
() AS T2
Select DBA_USERS. Username
DBA_HIST_ACTIVE_SESS_HISTORY. Machine
COUNT (*) AS CONN_COUNT
of DBA_HIST_ACTIVE_SESS_HISTORY
DBA_USERS
where DBA_HIST_ACTIVE_SESS_HISTORY. User_id = DBA_USERS. User_id
and DBA_USERS. Username like would be %'
and DBA_HIST_ACTIVE_SESS_HISTORY. Machine not as "WINAD%\%-%".
Group of DBA_USERS. Username
DBA_HIST_ACTIVE_SESS_HISTORY. Machine
order by 1
3 desc)
SELECT T1. TLA
, T1. USED_ID
, T2. MACHINE
, T2. CONN_COUNT
, T1. OWNER
FROM T1
T2
WHERE T1. USED_ID = T2. USER NAME;
-
How to find the difference between two dates in the presentation layer
Hi gurus,
Hello to everyone. Today, I came with the new requirement.
I need to know the difference between a date and the current date in the formula column application presentation layer.by.
Thank you and best regards,
PratesHi Navin,
TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".
If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...
hope you understand...
Award points and to close the debate, if your question is answered.
See you soon,.
Aravind -
Dynamic action - Get the difference between two dates + times
I have problems a little dynamic to work action. I'm trying to get the time between two dates with the time difference.
Here is what I got (this is apex 4.0):
Two date pickers + two numbers fields (date/start/end times)
I created a dynamic action on the page who fires on the point lose focus (above points).
The real action for the DA is the body of the PL/SQL function:
When I change the values on the page, I get the following error:declare end_date DATE; start_date DATE; Begin start_date := to_char(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MON-YYYY HH:MIAM'); end_date := to_char(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MON-YYYY HH:MIAM'); :P1_HOURS := end_date-start_date; End;
AJAX call back Server error ORA-06502: PL/SQL: digital or value error: character number conversion error to set the value.
I'm guessing that there is a problem with the date formatting, but I can't make it work. Thanks in advance!Hi djston,
because you chose the dynamic action of 'Set value' with the "Body of the PL/SQL function" type you need to return the value. Try the following code
declare end_date DATE; start_date DATE; Begin start_date := to_date(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MM-YYYY HH:MIAM'); end_date := to_date(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MM-YYYY HH:MIAM'); RETURN (end_date-start_date)*24; End;
and P1_REQUESTED_HOURS like 'item affected. "
Concerning
Patrick
-----------
My Blog: http://www.inside-oracle-apex.com
APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolfPublished by: Patrick Wolf on January 17, 2011 10:54
-
compare the fields of two queries
I need to compare the fields of two queries.
I went through many articles to asktom help operator less. but I'm not convinced by this method.
Comaprisons are for about 10 fields.
So I'm planing to do using sliders and nested loops. performance can be a problem.
Please give your suggestions or solutions.OK, using the data you provided, I get this:
with map_test_fac as (select 100 idid, 789 ifid, 300 edid, 741 efid from dual union all select 100 idid, 123 ifid, 300 edid, 963 efid from dual union all select 100 idid, 456 ifid, 300 edid, 258 efid from dual), test_fac as (select 741 facid, 'ETY' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all select 789 facid, 'WE' type, 'EUR' ccy, 'Int' src, 100 did from dual union all select 123 facid, 'VPR' type, 'EUR' ccy, 'Int' src, 100 did from dual union all select 456 facid, 'ETY' type, 'USD' ccy, 'Int' src, 100 did from dual union all select 963 facid, 'WE' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all select 258 facid, 'VPR' type, 'EUR' ccy, 'Ext' src, 300 did from dual) -- end of mimicking your data: USE SQL below: select tfi.facid int_facid, tfi.type int_type, tfi.ccy int_ccy, tfi.src int_src, tfi.did int_did, tfe.facid ext_facid, tfe.type ext_type, tfe.ccy ext_ccy, tfe.src ext_src, tfe.did ext_did from test_fac tfi, test_fac tfe, map_test_fac mtf where mtf.ifid = tfi.facid and mtf.efid = tfe.facid and mtf.idid = tfi.did and mtf.edid = tfe.did and (tfi.type != tfe.type or tfi.ccy != tfe.ccy) INT_FACID INT INT INT INT_DID EXT_FACID EXT EXT EXT EXT_DID ---------- --- --- --- ---------- ---------- --- --- --- ---------- 789 WE EUR Int 100 741 ETY EUR Ext 300 123 VPR EUR Int 100 963 WE EUR Ext 300 456 ETY USD Int 100 258 VPR EUR Ext 300
However, I think that your mapping data is incorrect, so with keys of information:
with map_test_fac as (select 100 idid, 789 ifid, 300 edid, 963 efid from dual union all select 100 idid, 123 ifid, 300 edid, 258 efid from dual union all select 100 idid, 456 ifid, 300 edid, 741 efid from dual), test_fac as (select 741 facid, 'ETY' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all select 789 facid, 'WE' type, 'EUR' ccy, 'Int' src, 100 did from dual union all select 123 facid, 'VPR' type, 'EUR' ccy, 'Int' src, 100 did from dual union all select 456 facid, 'ETY' type, 'USD' ccy, 'Int' src, 100 did from dual union all select 963 facid, 'WE' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all select 258 facid, 'VPR' type, 'EUR' ccy, 'Ext' src, 300 did from dual) -- end of mimicking your data: USE SQL below: select tfi.facid int_facid, tfi.type int_type, tfi.ccy int_ccy, tfi.src int_src, tfi.did int_did, tfe.facid ext_facid, tfe.type ext_type, tfe.ccy ext_ccy, tfe.src ext_src, tfe.did ext_did from test_fac tfi, test_fac tfe, map_test_fac mtf where mtf.ifid = tfi.facid and mtf.efid = tfe.facid and mtf.idid = tfi.did and mtf.edid = tfe.did and (tfi.type != tfe.type or tfi.ccy != tfe.ccy) INT_FACID INT INT INT INT_DID EXT_FACID EXT EXT EXT EXT_DID ---------- --- --- --- ---------- ---------- --- --- --- ---------- 456 ETY USD Int 100 741 ETY EUR Ext 300
That's more like what you're looking for?
-
How to quickly find the difference of two version of RPD?
Hi all
Someone has a good idea to quickly find the difference of two versions of the RPD in the project?
Kind regards
AnneThis could be a help for you
http://varanasisaichand.blogspot.com/2010/03/how-to-merge-two-repositories.html
http://www.rittmanmead.com/2010/07/OBIEE-11gr1-incremental-patches-to-the-RPD/See you soon,.
KKPublished by: Kranthi.K on December 7, 2011 21:41
-
Find the difference between two date and time
Hi friends,
I wanted to find the difference between two date and time, but my qury is slightest error "invalid number."
select sql_step_num,proc_name,run_seqno,start_date,end_date,(to_char(start_date,'HH24-MI-SS') - to_char(end_date,'HH24-MI-SS') ) as ed from eval.EVAL_RUNTIME_DETAILS where trunc(start_date) = trunc(sysdate) order by sql_step_num;
You try to get the feel between two char strings.
And more difference between two dates gives a NUMBER of days.
Try this:select sql_step_num,proc_name,run_seqno,start_date,end_date,numtodsinterval(end_date-start_date,'DAY') as ed from eval.EVAL_RUNTIME_DETAILS where trunc(start_date) = trunc(sysdate) order by sql_step_num;
-
How to calculate the difference between two times by the NUMBERS
I'm so bothered by the fact that I can't understand that.
Cell B2 - 08:00
Cell C2 - 10:50
(How can cell D2 - I get this cell to calculate the difference and say 02:50?)
I know it's probably one of the most basic operations, but for the life of me I can't understand it. The cells B2 and C2 are formatted for a 24-hour clock. But if I tell the system to just subtract the two, I get "0,118. Everything I find on the forum search goes beyond what I need. Can someone help me?
Thank you
Hi sapirs,
Departure and arrival of the cells are in Date and time with Date format: no and time: 24-hour clock.
Formula in D2 (fill down)
= C2−B2
The results become a duration format, but under automatic (numbers automatically worth this format)
If you wish, you can change the cells of lasting results.
What Data Format have your result cells?
Kind regards
Ian.
-
outer join: difference between two queries
Below two queries which should give the same results in my opinion. I want that all records of u_protocol and the pval.u_protocol_variable_value value if necessary.
Why the outer join in query2 does not work as in query1?
Query1:
Query2:select p.u_protocol_id, i.u_protocol_variable_value from lims_sys.u_protocol p, ( select pval.u_protocol_id, pval.u_protocol_variable_value from lims_sys.u_protocol_variable pvar, lims_sys.u_protocol_value_user pval where pvar.u_protocol_variable_id = pval.u_protocol_variable_id and pvar.name = 'VALUE_Protocol_Group' ) i where p.u_protocol_id = i.u_protocol_id (+)
select prt.u_protocol_id, pval.u_protocol_variable_value from lims_sys.u_protocol prt, lims_sys.u_protocol_variable pvar, lims_sys.u_protocol_value_user pval where pvar.u_protocol_variable_id = pval.u_protocol_variable_id and prt.u_protocol_id = pval.u_protocol_id (+) and pvar.name = 'VALUE_Protocol_Group'
Hello
When you perform an outer join, all conditions on the tables in option must be outer join conditions. Otherwise, the effect is an inner join.
There is one exception: cascade of outer joins, external-junction b of a and c is outside attached to b. In this case, in the b - c join only columns of c are marked with the sign +.Re - write to obtain the same results as query1, query2 like this:
select prt.u_protocol_id , pval.u_protocol_variable_value from lims_sys.u_protocol prt , lims_sys.u_protocol_variable pvar , lims_sys.u_protocol_value_user pval where pvar.u_protocol_variable_id (+) = pval.u_protocol_variable_id -- cascading outer join and prt.u_protocol_id = pval.u_protocol_id (+) and pvar.name (+) = 'VALUE_Protocol_Group' -- (+) added ;
I find the syntax ANSI easier to use for all the joins and much easier for outer joins.
-
Computer with Vista unable to connect to the internet through two computers with Windows 7.
Dear engineers,
In our House, we have two new computers Windows 7 connect to Wired internet access. Our friend came in hoping to play some MMO games with us on our connection (it has windows vista). When we hung everything upward, by linking to our modem, his computer was visible on my husbands computer, but was visible on mine as a media device. He could see the two computers, but could not get an internet connection and no viable ping. We checked the network map and he showed my computer with one? related to my husband then connected to the internet. Inside, there was an announcement indicating that the following devices are not displayed in the network map. under of course was listed both our friends media device and the computer device. I searched Control Panel and gave access to anyone on the login to my husbands system as long as me. What happens if nothing else can I try to have its system you can connect to our internet?
Thank you for your attention,
Cerisea
Hello
If a computer is not properly visible it generally means that sharing is not set correctly to match your system.
You must also set your computers with the computer account of the friend as a user on your computer.
Everyone does not mean everyone wishing to connect.
If the accounts are presented only for John, Jill and Jack, setting in the folder with all permissions saves the effort of definition permission separately for John, Jill and Jack.
Everyone isn't everyone group, only John, Jill and Jack.
In general.
Win7 when configured on the peer-to-peer network has three types of configurations of sharing.
Group residential network = only works between Win 7 computers. This type of configuration, it is very easy to entry level users to start sharing network.
Working network = fundamentally similar to previous methods of sharing that allow you to control what, how and to whom the records would be shared with.
Public share = network Public (as Internet Café) in order to reduce security risks.For the best newspaper of the results of each computer screen system and together all computers on a network of the same name, while each computer has its own unique name.
http://www.ezlan.NET/Win7/net_name.jpg
Make sure that the software firewall on each computer allows free local traffic. If you use 3rd party Firewall on, Vista/XP Firewall Native should be disabled, and the active firewall has adjusted to your network numbers IP on what is sometimes called the Zone of confidence (see part 3 firewall instructions
General example, http://www.ezlan.net/faq#trusted
Please note that some 3rd party software firewall continue to block the same aspects it traffic Local, they are turned Off (disabled). If possible, configure the firewall correctly or completely uninstall to allow a clean flow of local network traffic. If the 3rd party software is uninstalled, or disables, make sure Windows native firewall is active .Win 7 networking with other version of Windows as a work network.
In the center of the network, by clicking on the type of network opens the window to the right.
Choose your network type. Note the check box at the bottom and check/uncheck depending on your needs.
http://www.ezlan.NET/Win7/net_type.jpg
Win 7 network sharing folder specific work - http://www.onecomputerguy.com/windows7/windows7_sharing.htm
Vista file and printer sharing - http://technet.microsoft.com/en-us/library/bb727037.aspx
When you have finished the configuration of the system, it is recommended to restart everything the router and all computers involved.
-------------
If you have authorization and security problems, check the following settings.
Point to a folder that wants to share do right click and choose Properties.
In the properties
Click on the Security tab shown in the bellows of the photo on the right) and verify that users and their permissions (see photo below Centre and left) are configured correctly. Then do the same for the authorization tab.
This screen shot is to Win 7, Vista menus are similar.
http://www.ezlan.NET/Win7/permission-security.jpg
The Security Panel and the authorization Panel, you need to highlight each user/group and consider that the authorization controls are verified correctly.
When everything is OK, restart the network (router and computer).
* Note . The groups and users listed in the screen-shoot are just an example. Your list will focus on how your system is configured.
* Note . There must be specific users. All means all users who already have an account now as users. This does not mean everyone who feel they would like to connect.
---------------------
*** Note. Some of the processes described above are made sake not for Windows, but to compensate for different routers and how their firmware works and stores information about computers that are networked.
Jack-MVP Windows Networking. WWW.EZLAN.NET
-
Take the difference of two tables
Hello
I have two tables where in I need to take the difference between the two columns of different tables and show as decimal below:
Table A
Name, salary
x 10.5
y - 10.32
z 5
Table B
Name, salary
x 10.5
y - 10.32
z 3
a 12
Output:
Name_A, Name_B, salary, remarks
x, x, 0, no diff
y, y, 0, no diff
z, z, 2 Diff is here
, one, no data, no data from the previous
Hello
Try ythis:
with table_a as
(
SELECT 'X' NAME, SALARY, 10.5 DUAL UNION ALL
SELECT THE NAME OF 'Y',-10.32 SALARY OF DOUBLE UNION ALL
SELECT THE NAME OF 'Z', 5 DOUBLE SALARY
)
table_B as
(
SELECT 'X' NAME, SALARY, 10.5 DUAL UNION ALL
SELECT THE NAME OF 'Y',-10.32 SALARY OF DOUBLE UNION ALL
SELECT THE NAME OF 'Z', 3 DOUBLE UNION ALL SALARIES
SELECT 'A' NAME, SALARY 12 DUAL FROM
)
SELECT
COALESCE(A.NAME,B.NAME) NAME
, NVL (TO_CHAR (A.SALARY - B.SALARY), 'NO DATA') SALARY
, CASE WHEN A.SALARY - B.SALARY = 0 THEN 'NO DIFFERENCE '.
WHEN B.SID IS NULL, "NO DATA OF THE PREVIOUS.
WHERE B.NAME IS NULL, "NO DATA FROM NEXT.
ANOTHER 'DIFFERENCE IS THERE.
END NOTEOf
TABLE_A HAS
TABLE_B FULL OUTER JOIN B ON (B.SID = B.NAME)
;NAME SALARY NOTE
---- ---------------------------------------- ---------------------
X 0 NO DIFFERENCE
Y 0 NO DIFFERENCE
Z 2 THE DIFFERENCE IS THERE
A NUMBER OF DATA NO DATA FROM THE PREVIOUSKind regards
Peter
-
How to find the difference between two dates in time except Sunday
Hi all
I have a table, as shown below.
I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.SQL> select * from test; TR_ID CREATE_TIME CODE -------------------------------------------------- --------------------------------------------------------------------------- ---------- S12341 05-JUN-12 12.20.52.403000 AM 1003 S12342 11-JUN-12 11.15.33.182000 AM 1003 S12342 07-JUN-12 12.00.36.573000 PM 1002 S12343 20-JUN-12 12.34.37.102000 AM 1003 S12343 15-JUN-12 11.34.27.141000 PM 1002 S12344 01-JUL-12 10.01.06.657000 PM 1002 S12344 06-JUL-12 12.01.04.188000 AM 1003 S12341 31-MAY-12 11.20.38.529000 PM 1002
For example:
TR_ID: S12344
1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
1003_Create_time: 12.01.04.188000 AM 6 July 12
1002 create time is 22:00 Sunday.
If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.
I tried the sub query after doing a search on this forum but I am not getting the desired output.
Need help to get the desired o/pSELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
Hello
If I unederstand the problem correctly, that's what you want:
WITH got_extrema AS ( SELECT tr_id , CAST (MIN (create_time) AS DATE) AS start_date , CAST (MAX (create_time) AS DATE) AS end_date FROM test GROUP BY tr_id ) SELECT tr_id , start_date, end_date -- If wanted , 24 * ( ( ( TRUNC (end_date, 'IW') -- Count -1 day for every full week - TRUNC (start_date, 'IW') ) / -7 ) + LEAST ( end_date -- If end_date is a Sunday , TRUNC (end_date, 'IW') + 6 -- consider it 00:00:00 on Sunday ) - CASE WHEN start_date >= TRUNC (start_date, 'IW') + 6 -- If start_date is a Sunday THEN TRUNC (start_date, 'IW') + 6 -- consider it 00:00:00 Sunday ELSE start_date END ) AS total_hours FROM got_extrema ;
I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.
Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
(a) 1 day is deducted for each week between start_date and end_date
(b) if End_date is a Sunday, none of the end_date himself hours are counted
(c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.
Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002} -
The most elegant way to get the difference between two tables - not least!
Hello
Simplified example of what I'm trying to achieve - I have two tables ORIGINAL and REVISED.
My aim is to compare the two, such as; -
When there is data in the two tables I get the difference between the Budget column, and if there is no difference, so I don't want no lines.
When data exists in the ORIGINAL, but not in review, I want to the inverse of the current value of the Budget column.
Where the data exist in REVISED I want the REVISED value.
I can see how I can do this, see below, but is there a more elegant solution?
Data for the ORIGINAL table
Data for the REVISED tableselect '801040' entity, '2186' expense_type, 234000 budget from dual union all select '801040' entity, '3001' expense_type, 1000 budget from dual union all select '801040' entity, 'P132' expense_type, 34000 budget from dual union all select '801040' entity, 'P135' expense_type, 43000 budget from dual
Desired outputselect '801040' entity, '2186' expense_type, 235000 budget from dual union all select '801040' entity, 'P132' expense_type, 34000 budget from dual union all select '801040' entity, 'P139' expense_type, 56000 budget from dual
ENTITY EXPENSE_TYPE DIFFERENCE
------ ------------ ----------
801040 2186 1000
801040 3001-1000
801040 P135-43000
801040 P139 56000
5 selected lines.
Code current to achieve this, is there a better way?
Thanks a lot for your comments,.select original.entity , original.expense_type , (nvl(revised.budget,0) - original.budget) as difference from original , revised where original.entity = revised.entity(+) and original.expense_type = revised.expense_type(+) and (nvl(revised.budget,0) - original.budget) != 0 union all select revised.entity , revised.expense_type , revised.budget as difference from revised where not exists (select 'x' from original where original.entity = revised.entity and original.expense_type = revised.expense_type) and revised.budget != 0
Robert.
Published by: Robert Angel on January 17, 2012 03:31 to change is not equal to! = - Thanks for the heads upSQL> with original 2 as 3 ( 4 select '801040' entity, '2186' expense_type, 234000 budget 5 from dual 6 union all 7 select '801040' entity, '3001' expense_type, 1000 budget 8 from dual 9 union all 10 select '801040' entity, 'P132' expense_type, 34000 budget 11 from dual 12 union all 13 select '801040' entity, 'P135' expense_type, 43000 budget 14 from dual 15 ) 16 , revised 17 as 18 ( 19 select '801040' entity, '2186' expense_type, 235000 budget 20 from dual 21 union all 22 select '801040' entity, 'P132' expense_type, 34000 budget 23 from dual 24 union all 25 select '801040' entity, 'P139' expense_type, 56000 budget 26 from dual 27 ) 28 select * 29 from ( 30 select nvl(o.entity, r.entity) entity, 31 nvl(o.expense_type, r.expense_type) expense_type, 32 nvl(r.budget,0) - nvl(o.budget,0) budget 33 from original o 34 full join revised r 35 on o.entity = r.entity 36 and o.expense_type = r.expense_type 37 ) 38 where budget <> 0 39 / ENTITY EXPE BUDGET ------ ---- ---------- 801040 2186 1000 801040 P135 -43000 801040 3001 -1000 801040 P139 56000 SQL>
-
How can I compare the differences between two files After Effects?
I have a major problem. I was working on special effects for a film. In After Effects, when I change siggificant, I often have to register under and create a new name so I can go back to the old work if necessary. It comes in a case, I have come back from earlier works. If I use these two files After Effects allows you to create multiple clips of effects. And I do not remember just where you look at it, it is better. Does anyone know a good way to compare the differences between the files?
One thing to keep this conversation on the right way: I know that I did a stupid thing. I've never done this before so can we please not spend a lot of time on how to avoid this problem and stick to how we solve this problem?
If you encounter difficulties to identify differences in the old and new versions, you can use this procedure:
To avoid confusion, I'll call your former company and your most recent compositions CompB comps.
CompA drag "New Comp" icon in the project window. This will create a new temporary layout that contains the nested CompA.
Drag in your new COMP CompB temporary ensure it aligns image for image with CompA.
Place the top layer (CompB) difference.
Now, when you play through the comp, you'll see differences in color at a time where the comparison and CompB are not identical.
-
How to tell the difference between two dates
Hello:
I have a question on how to get the difference in quantities for two dates in the replies and dashboard.
This is the scenario. I have two guests date and three columns. The first column must be the sum of the amounts for the first quick date. The second column should be the sum of the amounts for the second fast date. And the third column is the difference between the first two columns.
Basically, I'm trying to do something similar to a function of sum of two lines but trying to get the difference between the two rows. Any help to solve this problem would be appreciated.Use the COLUMN FILTERS level...
the first column with the first variable of date quick presentation of the filter
Similarly, the second column in the second variable of quick overview of date filter
Kind regards
Rambeau
Maybe you are looking for
-
remove trojan generickd.2701147
How can I remove the Trojan generickd.2701147 for my macbook?
-
Ethernet controller, PCI Simple communications controller and for desktop sm bus controller
Hello I'm having a problem with the following drivers after installing windows 64-bit edition Home premium. I shared the ID of material for them. Controller 1) Ethernet PCI\VEN_8086 & DEV_1503 & SUBSYS_20178086 & REV_05PCI\VEN_8086 & DEV_1503 & SUBSY
-
How it's to use an add-on?
Just wanted to know how of course is to use modules that are developed by other developers of mozilla?When installing an add-on on firefox warns to add not reliable on the authors. But most of the addons are not reliable. How to ensure the safety and
-
I have having many errors of registry HKEY - LOCALMACHINE\SOFTWARE\CURRENTVERSION\INSTALLER\FOLDERS VALUE IS MISSING or INVALID HKEY-USERS\5-1-5-21-169808-764733703-11772389-501\SOFTWARE/MICROSOFT/WINDOWS VALUE IS MISSING OR INVALID NT\CURRENTVERSION
-
Hello Admin HP I have hp pavilion dm1, which I do not know what region it is I am trying all the famous part if you could find this please tell me who is - this here is a snapshot of the product name and serial number Please tell me exactly a link wh