Time difference issue - need a better way

Hi
I need to display the difference in time - every day for different time ranges,
Example 1-2 pm, 4-5 pm, 7-8 pm. And I need the time difference in 2 dates in the past week for each of these ranges everyday.
example
Date Diff Range
01/01/2007 00:01 1-2pm
01/02/2007 00:03
01/03/2007 00:10
01/04/2007 00:05
01/05/2007 00:23
01/01/2007 00:10 4-5pm
01/02/2007 00:13
01/03/2007 00:11
01/04/2007 00:15
01/05/2007 00:23
01/01/2007 01:10 7-8pm
01/02/2007 00:13
01/03/2007 00:10
01/04/2007 00:11
01/05/2007 00:21
One way to achieve this is to have multiple unions for each day and each time range.
Example:
select
from
where dt_tm between
to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 13:00','mm/dd/yyyy hh24:mi:ss')and
to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 14:00','mm/dd/yyyy hh24:mi:ss')
union
select
from
where dt_tm between
to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 16:00','mm/dd/yyyy hh24:mi:ss')and
to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 17:00','mm/dd/yyyy hh24:mi:ss')
union
select
from
where dt_tm between
to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 19:00','mm/dd/yyyy hh24:mi:ss')and
to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 20:00','mm/dd/yyyy hh24:mi:ss')
This will give me the required information for only one day - and that is for sysdate-5.
I will have same nyumber of unions for each day.
Is there a better way to accomplish the same?
Any help appreciated.
Thx!

Time difference by date by time range - a better way?

Similar Messages

  • BW System with 2 factory calenders - Time Difference - Issue

    I have 2 source systems for our BI Implementation, which inturn maintains 2 factory calenders---> IN and KR.
    I am creating 2 reports based 2 source systems (using different factory calender).
    the reports need to calculate the time diff between 2 dates(D1, D2) and 2 times(T1 and T2) into hours based on factory calender. Report 1 based on IN calender and Report 2 based on KR Calender.
    But Both the reports are giving the same time difference, even though the No. of working days are different for each factory calender.
    For Eg : D1 - 2007.12.01; D1 - 2007.12.31; T1 - 00:00:00; T2 - 00:00:00
    I have used the FM :  SALP_SM_CALC_TIME_DIFFERENCE, to calculate the time diff.
    In report 1 the time diff = 30 days ( since 1 holiday in Dec month based on IN Calender)
    In report 2 the time diff should be 28 days ( since 3 holidays in Dec month based on KR Calender ), but its also giving 30 days as timediff.
    Plz provide the solution.
    Thanks
    Shekar.

    Any Info.
    Shekar

  • Time difference issue between actual and system internal time..

    Hi,
    We have PCCE v9.0.3 running in our network.
    We see time difference of mor than 30 minutes between CUIC reports and SQL quries output for the calls.
    I checked system time for all components along with NTP source, all good.However the RTTEST and PROCMON utilities STATUS command output shows the local time is behind actual time.
    I have attached the snapshot of this.
    Thanks!

    Not exactly true:
    User SYS is the owner of the data dictionary. In fact, SYS is the owner of the entrire structure of the database. The datadictionary is stored in the SYS-schema (a user = a schema)
    SYSTEM is an account with many privileges and is used as an administrator account. SYSTEM owns some objects, but not the data dictionary
    The tablespace SYSTEM is the tablespace in which the SYS schema (and SYSTEM schema as well) is stored. The names of the SYSTEM account and SYSTEM tablespace have nothing to do with each other, not as far as I know anyway

  • Need a better way than killing connections in SQL Azure - Governor

    I've been pushing the boundaries of  SQL azure (S0 and S1) recently. 
    I'm at a point where normal T-SQL code needs to be optimized for SQL azure, I was surprised that all Microsoft have done was enhance the governor process and kill the connection  rather than slow down the connection, guess this was the easy path to
    use. 
    Simple T-SQL statements like MERGE need to be rewritten to support large data (1 million rows).  Given you need to batch core T-SQL commands you need to answer yourself is this the correct approach.  Also had the same issue using SQL Bulk Copy
    but tweaked a few settings to get around that issue. 
    S0 & S1 still haven't got the same IO as Web/Business edition hence Microsoft need to fix this ASAP.
    Is SQL Azure worth that extra hassle compared with other DB engines?
    Micatio Software Free IIS Azure Web Log App

    Hi Jan,
    Its not the command timeout (for example set as 0 in SQL management studio). 
    I've seen it many times where the last wait type is the LOG GOVERNOR. 
    A few minutes later the status is set as KILLED/ROLLBACK.  I can get around the issue by batching the MERGE statement  and it works fine.  
    I would understand if the MERGE was running for 1-2 hours and I've seen the same thing occur when using a bulk insert command in C# (resolved by limiting the batch size, streaming, etc.).
    The azure version is Microsoft SQL Azure (RTM) - 11.0.9230.176.
    The log governor does kill connections, this is documented on a few sites and MSDN.  LOG GOVERNOR was a SQL Enterprise feature in the standalone product except Microsoft in there wisdom ported it across into SQL Azure to resolve users running bad queries
    on the infrastructure.
    Micatio Software Free IIS Azure Web Log App

  • Need a better way to reset selected cells in a table

    Hello all,
    I have been looking at the various threads discussing resetting only selected fields in a form and leaving others unchanged.
    The form I am working on has a table of 20 body rows with 8 columns. I want to have a reset button that resets 6 of the cells in each row.
    I am using the following snippet:
    for (var nRow = 1; nRow < 21; nRow++)
    for (var nCell = 0; nCell < 6; i++)
    xfa.host.resetData("form1.page1.wrapper.ICC.Table1.Row[" + nRow + "].rate[" + nCell + "]");
    This works but is extremely slow (on the order of 10 seconds) and my pc is no slouch.  There has to be a simpler (and faster!) way to do this.
    I saw one thread where the cells that were to be spared from the reset could be listed but just could not make that work at all. I thought about putting the cells to be spared into a subform but that went nowhere, as I was only able to place individual cells into separate subforms.
    Any suggestions will be welcome ... with formcalc script if possible:)
    Thanks.
    Harry Ohm.
    edit: Now it appears it does not work as I first thought. It works on a single row but not when the nested for loops are used.
    Message was edited by: HarryOhm

    Hi Harry,
    Just two small issues. I would wrap the first for loop in {} and then you have i++ in the second loop:
    for (var nRow = 1; nRow < 21; nRow++)
         for (var nCell = 0; nCell < 6; nCell++)
              xfa.host.resetData("form1.page1.wrapper.ICC.Table1.Row[" + nRow + "].rate[" + nCell + "]");
    It looks like your table is static (rows do not repeat). One option would be to build up a variable/string with the objects names and then reset that. This is a reset example from one of our forms (http://assure.ly/gBJYj9). Here it is resetting one row and two fields outside of the table:
    // reset page 6 only
    var f1 = Table1.Row1.description.somExpression + ", ";
    var f2 = f1 + Table1.Row1.quantity.somExpression + ", ";
    var f3 = f2 + Table1.Row1.unitPrice.somExpression + ", ";
    var f4 = f3 + positionedSF.myName.somExpression + ", ";
    var f5 = f4 + positionedSF.myAddress.somExpression;
    xfa.host.resetData(f5);
    Hope that helps,
    Niall
    Assure Dynamics

  • 2pin (USA) and 3pin (UK) Charger: Charging time differences. Need help.

    I had my iPhone 3Gs imported from USA. It is unlocked from AT&T, but thats not the point. I got the Apple original 2pin charger with it.
    Now, I have recently got a new iPhone 4, imported from UK. It comes it an original Apple 3pin charger, as common in UK.
    In my country, I can use both types of chargers. As far as I know, both supply the same amount of power. The thing is: my iPhone 4 (3pin) charger takes around 5hours to charge my phone from 10-100%. The battery lasts for a day at most. Now if I use my 3Gs charger (2pin) with my iPhone 4, it charges incredibly fast. From 10-100%, it takes an hour and a half at most. The battery lasts for a day with this charger as well.
    Now, my question: is there any difference in the amount of power supplied from both chargers? Will using the 2pin (original) charger with my iPhone 4 somewhat damage it? Like excess current short circuiting the internal power supply or whatnot? Because I like the battery to get charged quickly, but I cant risk short circuiting it (there's no Apple Store around my place for miles, so I cant take my iPhone to one in case I damage it.)
    Experts please help. Thanks.

    A charging time of about an hour and a half to go from 10-100% doesn't seem to be unreasonable.  My figures are based on using the iPhone charger.  Using an iPad charger will charge the battery quicker, but I have not done any time testing using my iPad charger.  This is because the iPad charger can put out 2.1 amps as opposed to the iPhone charger that puts out 1 amp.  Using a charger that puts out more amps than required shouldn't hurt your iPhone since the iPhone should limit the amount of amps it draws.
    5 hours to charge your iPhone seems slow.  Does the 3 pin charger say it outputs 5v, 1 amp?

  • Calendar synch time difference issue

    When I synch between my Windows VIsta Calendar and my Blackberry Curve 9300, appointments synching from my Windows Calendar appear on my Blackberry two hours earlier yet both calendars are set to GMT,
    Can anyone help me to solve this issue?
    Many thanks
    Dan

    Hello corndoll and welcome to the BlackBerry® Support Community Forums.
    Have you checked the Time Zone setting in your Microsoft® Outlook® to ensure it's set to the same as your device and computer?
    When you create a new appointment in Outlook, is the Time Zone being used the correct one?
    In your Device, when you go to create a new appointment, is the proper TIme Zone being displayed when creating the appointment? 
    Thanks!
    -HMthePirate
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • I need a better way....

    I have created a package to grab data from separate production systems into a single oracle table.
    The oracle table contains all files processed in history (with a processed flag set to 1, initially set to 0)
    after the packages run to get all the data and place it into the Oracle table, i need to take all that data and push it into a text file so it can be SFTP to another location.
    My package is setup like this:
    1.Start Bell (This is just to let people know quickly where the start of the package is)
    2.Set TrueOrFalse Variable to False (This is incase there is nothing to process and it will exit one the packages are run if no data exists)
    3.Packages: Get Data 1, Get Data 2, Get Data 3, Get Data 4 (There are 4 packages that get all the data and push into my Oracle DB, usually this table has about 20,000+ records in it)
    4.Variable: "Are there any records" (This does a simple count(*) query to see if there are any records)
    5.Variable: "Still Have Records" (This evaluates step 4 for > 0)
    5a.(True) Set TrueOrFalse Variable to True (Yes we have at least 1 record) Goto Step 6
    5b.(False) Evaluate TrueOrFalse Variable. Goto Step 10
    6.Get first Row and format: id || ', ' || pnumber || ', ' || current_due || ', ' || total_due || CHR(13) || CHR(10)
    7.Push data from Step 6 into and OdiOutFile (text file)
    8.Update Oracle Table (set processed = '1')
    9.Goto Step 4
    10.Check TrueOrFalse Variable (If no records this will be False, if processed one record this will be True)
    10a.(True) Send File Via SFTP.
    10b.(False) Email Nothing to Check to programmer
    11 Finish Bell
    The first part, up to Step 4, runs smoothly and gets all my data into my Oracle Table (Called Matrix). I was told by someone previously that to process each record i need to look at each one individually and then push each one individually into the text file (OdiOutFile)...
    Is there a quicker way to have ODI take a query from the table, say something like:
    Select id || ', ' || pnumber || ', ' || current_due || ', ' || total_due || CHR(13) || CHR(10)
    From OracleTable
    Where processed = '0'
    and push that into the OdiOutFile? Or do i have to run it pulling each line individually?
    Hope this makes at least some sense...
    Tom Cusick

    Thanks this did the trick... actually i got an email from Cezar just before you posted this with the same answer... Thanks to both!!!

  • Time difference by date by time range - a better way?

    Someone suggested this is a better place for my question:
    Hi
    I need to display the difference in time - every day for different time ranges,
    Example 1-2 pm, 4-5 pm, 7-8 pm. And I need the time difference in 2 dates in the past week for each of these ranges everyday.
    example
    Date Diff Range
    01/01/2007 00:01 1-2pm
    01/02/2007 00:03
    01/03/2007 00:10
    01/04/2007 00:05
    01/05/2007 00:23
    01/01/2007 00:10 4-5pm
    01/02/2007 00:13
    01/03/2007 00:11
    01/04/2007 00:15
    01/05/2007 00:23
    01/01/2007 01:10 7-8pm
    01/02/2007 00:13
    01/03/2007 00:10
    01/04/2007 00:11
    01/05/2007 00:21
    One way to achieve this is to have multiple unions for each day and each time range.
    Example:
    select
    from
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 13:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 14:00','mm/dd/yyyy hh24:mi:ss')
    union
    select
    from
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 16:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 17:00','mm/dd/yyyy hh24:mi:ss')
    union
    select
    from
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 19:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 20:00','mm/dd/yyyy hh24:mi:ss')
    This will give me the required information for only one day - and that is for sysdate-5.
    I will have same nyumber of unions for each day.
    Is there a better way to accomplish the same?
    Any help appreciated.
    Thx!

    Hi
    Sorry for the late response but better late than never:::
    I have gotten the answer of getting data for previous 5 days. I have changed the time between statement and is given below(*).
    Here is a reply to all the questions you had asked in response to my questions.
    What data you have? What parameters are you going to input?
    I have already given sample data in my post.
    There are no input parameters.
    You are talking about the difference - between what is this difference?
    Difference is the difference between 2 timestamp datatypes in 2 different tables (as you may see in the query)
    The field diff - is it varchar2 like '1-2 pm' or what?
    I didnt understand your question. What do you get when you subtract two timestamp datatypes - that should be the datatype - if I have understood your question. Not sure if thats what you asked.
    But IMHO it's impossible to get such a result, of course, if dt_tm in the query is the same as Date in the result!
    The time components in the queries are different. If you see:
    1st Query:...
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 13:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 14:00','mm/dd/yyyy hh24:mi:ss')
    2nd Query:....
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 16:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 17:00','mm/dd/yyyy hh24:mi:ss')
    3rd Query:
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 19:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 20:00','mm/dd/yyyy hh24:mi:ss')
    First should be between 1 and 2 pm for sysdate-5.
    I need starting previous 5 days till sysdate.
    Second is between 4 and 5 pm again for sysdate-5.
    I need starting previous 5 days till sysdate.
    Same with 3rd.
    My final query is something like this:
    select t1.dt_tm, count(t1.id), '1 - 3 am' as period
    from table1 t1, table2 t2
    where t1.id = t2.id
    and dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 13:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 14:00','mm/dd/yyyy hh24:mi:ss')
    group by t1.dt_tm
    union
    select t1.dt_tm, count(t1.id), '4 - 5 pm' as period
    from table1 t1, table2 t2
    where t1.id = t2.id
    and dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 16:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 17:00','mm/dd/yyyy hh24:mi:ss')
    group by t1.dt_tm
    union
    select t1.dt_tm, count(t1.id), '7 -8 pm' as period
    from table1 t1, table2 t2
    where t1.id = t2.id
    and dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 19:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 20:00','mm/dd/yyyy hh24:mi:ss')
    group by t1.dt_tm
    I need for the last 5 days and what i can think of is have 5 different queries for past 5 days and 3 queries per day for the 3 different time periods. This would mean 15 queries. Was wondering if there is a better way to achieve the same?
    Any help appreciated.
    Thx!

  • Is there a better way to deal with Verizon and my DSL issues?

    My family and I have been with Verizon for as long as we've had broadband internet. For the past 5 years or so the internet has been shaky at best. For the most part it works, but a coupe times a year it stops working all together or becomes VERY intermittent (and is usually working by the time I get finished sitting on hold and the test the technician runs shows no problems). Every time I have to wrestle with the "tech support" on the phone and listen to a recording tell me the same things over and over again that never fix my problems.
    Every time my internet gets to this point, it requires a visit from a Verizon technician. Usually they go out into the neighborhood and find a length of cable and replace it. Usually that fixes my issues for a while, but I know it will happen again. It always happens again.  It seems to me that the entire length of line that my internet runs through is old, and needs to be replaced. Instead of fixing the problem before it actually becomes a problem, Verizon continues to leave me and my family without service for periods of time.
    Last week was the most recent time we dealt with this situation, which was fortunately short lived (Only all day Sunday, into Monday when the technician arrived). It's getting VERY tiring dealing with this situation over and over again, and it's getting offensive honestly. To hear the tech support person tell me that I will be charged $91 if the problem is found and is inside my house is ridiculous. I would understand if this was the first time this situation had occurred, or if I frequently reported non-issues. But no, I'm simply reporting the same issue that Verizon has failed to fix MANY times before. 
    Perhaps the most frustrating part of this, is that we've never been compensated for our lost service. Last year we lost service for an entire week. That's an entire week with no internet service at all. After we finally got it back, we spoke with the billing department and they told us that we would be credited for the week we lost service. At this point, we are yet to see any credit for the time we have been without the service we pay for. Perhaps we would have tried dealing with Verizon again to get our weeks credit, but attempting to contact someone in Verizon seems futile. Unless you're calling sales you end up sitting on hold for extended periods of time, only to be bounced from person to person until you get to someone that has no excuse not to pretend to help you. 
    Unless something changes, this is Verizon's last opportunity to keep our service. We have dealt with the loss of service followed by the insult of attempting to deal with Verizon's customer support for the last time. Next time it happens (and I'm sure there will be a next time) unless Verizon shows us that they are actually going to correct the problem, we will cancel our service and give our business to the competitor. This post is being written for a few reasons. I'm hoping that perhaps Verizon can give me a better way to contact someone locally when we have a problem (I would LOVE to speak with a regional manager, or even a local manager of some sort), or at least recognize that there is a problem that will end up costing them money. 
    Thank you,
    A long time customer.

    I've decided to give up the fight and go to another provider.  I have work to do and having to wait at speeds slower than dial up is insane.  At least with dial up I'd have some stability.  I can't even run speedtest because it won't connect.  At hotels, wi-fi, and hanging by blackberry the laptop works fine but to actually use dsl, nope.  Multiple machines and multiple browsers - it's all the same worthless bandwidth.  
    If they won't give you fios then there is no reason to stay.  They've been promising me the service is coming for the last 6 years.  They could have run it here by now for the postage they've spent trying to get me to switch to it even though it isn't available.  Waste, waste, waste ....

  • Need help to get alternate or better way to write query

    Hi,
    I am on Oracle 11.2
    DDL and sample data
    create table tab1 -- 1 millions rows at any given time
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date
    create table tab2 -- close to 100 million rows
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date,
    upd_date date
    insert into tab1 values (1,'ABCDEFG', 'XYZ','Y',sysdate);
    insert into tab1 values (2,'XYZABC', 'DEF','Y',sysdate);
    insert into tab1 values (3,'PORSTUVW', 'ABC','Y',sysdate);
    insert into tab2 values (1,'ABCDEFG', 'WYZ','Y',sysdate);
    insert into tab2 values (2,'tbVCCmphEbOEUWbxRKczvsgmzjhROXOwNkkdxWiPqDgPXtJhVl', 'ABLIOWNdj','Y',sysdate);
    insert into tab2 values (3,'tbBCFkphEbOEUWbxATczvsgmzjhRQWOwNkkdxWiPqDgPXtJhVl', 'MQLIOWNdj','Y',sysdate);I need to get all rows from tab1 that does not match tab2 and any row from tab1 that matches ref_cd in tab2 but key is different.
    Expected Query output
    'ABCDEFG',  'WYZ'
    'XYZABC',   'DEF'
    'PORSTUVW', 'ABC'Existing Query
    select
       ref_cd,
       key
    from
        select
            ref_cd,
            key
        from
            tab1, tab2
        where
            tab1.ref_cd = tab2.ref_cd and
            tab1.key    <> tab2.key
        union
        select
            ref_cd,
            key
        from
            tab1
        where
            not exists
               select 1
               from
                   tab2
               where
                   tab2.ref_cd = tab1.ref_cd
        );I am sure there will be an alternate way to write this query in better way. Appreciate if any of you gurus suggest alternative solution.
    Thanks in advance.

    Hi,
    user572194 wrote:
    ... DDL and sample data ...
    create table tab2 -- close to 100 million rows
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date,
    upd_date date
    insert into tab2 values (1,'ABCDEFG', 'WYZ','Y',sysdate);
    insert into tab2 values (2,'tbVCCmphEbOEUWbxRKczvsgmzjhROXOwNkkdxWiPqDgPXtJhVl', 'ABLIOWNdj','Y',sysdate);
    insert into tab2 values (3,'tbBCFkphEbOEUWbxATczvsgmzjhRQWOwNkkdxWiPqDgPXtJhVl', 'MQLIOWNdj','Y',sysdate);
    Thanks for posting the CREATE TABLE and INSERT statments. Remember why you go to all that trouble: so the people whop want to help you can re-create the problem and test their ideas. When you post statemets that don't work, it's just a waste of time.
    None of the INSERT statements for tab2 work. Tab2 has 6 columns, but the INSERT statements only have 5 values.
    Please test your code before you post it.
    I need to get all rows from tab1 that does not match tab2 WHat does "match" mean in this case? Does it mean that tab1.ref_cd = tab2.ref_cd?
    and any row from tab1 that matches ref_cd in tab2 but key is different.
    Existing Query
    select
    ref_cd,
    key
    from
    select
    ref_cd,
    key
    from
    tab1, tab2
    where
    tab1.ref_cd = tab2.ref_cd and
    tab1.key    <> tab2.key
    union
    select
    ref_cd,
    key
    from
    tab1
    where
    not exists
    select 1
    from
    tab2
    where
    tab2.ref_cd = tab1.ref_cd
    Does that really work? In the first branch of the UNION, you're referencing a column called key, but both tables involved have columns called key. I would expect that to cause an error.
    Please test your code before you post it.
    Right before UNION, did you mean
    tab1.key    != tab2.key? As you may have noticed, this site doesn't like to display the &lt;&gt; inequality operator. Always use the other (equivalent) inequality operator, !=, when posting here.
    I am sure there will be an alternate way to write this query in better way. Appreciate if any of you gurus suggest alternative solution.Avoid UNION; it can be very inefficient.
    Maybe you want something like this:
    SELECT       tab1.ref_cd
    ,       tab1.key
    FROM           tab1
    LEFT OUTER JOIN  tab2  ON  tab2.ref_cd     = tab1.ref_cd
    WHERE       tab2.ref_cd  IS NULL
    OR       tab2.key     != tab1.key
    ;

  • A better way to generate the needed XML?

    I am working on a 10.2 system and looking to see if there is a better way to generate the resulting XML than what I have come up with. Here is a test case and the output it generates. I don't really like querying the table for each column needed as the real table has eight columns I am pulling. I would like to make one pass on person_h and get the info needed instead of making eight passes, but not sure if it is possible.
    with person_h as
       (select 1 id, 'M' gender, 'W' race, '170' weight from dual union all
        select 1, 'M', 'W', '170' from dual union all
        select 1, 'M', 'W', '180' from dual union all
        select 1, 'M', NULL, '175' from dual union all
        select 1, NULL, 'W', NULL from dual
    select xmlelement("Person",
             (select xmlagg(xmlelement("Sex", gender))
                from (select distinct gender
                        from person_h
                       where id = 1
                         and gender is not null) pg),
             (select xmlagg(xmlforest(race as "Race"))
                from (select distinct race
                        from person_h
                       where id = 1) pg),
             (select xmlagg(xmlforest(weight as "Weight"))
                from (select distinct weight
                        from person_h
                       where id = 1) pg)
           ).getstringval()
      from dual;
    Output
    <Person>
      <Sex>M</Sex>
      <Race>W</Race>
      <Weight>170</Weight>
      <Weight>175</Weight>
      <Weight>180</Weight>
    </Person>Note: Previously posted on the XML DB forum at A better way to generate the needed XML? but still looking for other solutions so putting in front of more eyes here. I have considered using a WITH statement to do the initial query on person_h but haven't tested that yet to see what Oracle really will do as just getting back around to this lower priority task of mine.

    I'm using the WITH statement to simulate a table and DUAL/UNION ALL to create data in that "table". I've seen it used plenty of times in this forum so not sure why a problem for this example. The actual SQL/XML statement hits that "base table" three times, so I didn't include all eight columns because three columns is sufficient to show the problem in the way I coded the SQL. Following the SQL is the sample OUTPUT that SQL statement generates and that is the output I created and need. I'm just looking for other options to achieve the listed output.

  • DateDiff Help (Need time difference FROM Time 1 TO Time 2 - one direction)

    I hope I am putting this in the right section. This is my first post. Thank you all ahead of time for your help.
    I am new to both SQL and Report Builder so please bear with me and thank you ahead of time.
    I need to find the time difference (in minutes) between Time 1 and Time 2. I've figured out the basics in how to do this but I need the logic to work in ONE DIRECTION. Meaning I need the statement to find the difference STARTING FROM TIME 1 and then ENDING
    WITH TIME 2. I need the statement to always assume that Time 1 is FIRST and that Time 2 is LAST.
    Here's an example of my results now with a basic DateDiff statement.
    Time 1 | Time 2 | Time Difference (in minutes)
    11:30 | 1/15/2015 11:50:00 AM | 20
    23:50 | 1/15/2015 12:00:00 AM | 1430
    23:45 | 1/15/2014 2:05:00 AM | 1300
    Please note that Time 1 does NOT have a date at all and came over from its table as a simple 4 digit string so I had to convert it to datetime format using a concatenate statement. If it DID have a date then this probably wouldn't be a problem.
    Thoughts?
    Thanks.

    Thanks, Patrick. I'll look into understanding that (I'm still new to both SQL and Report Builder). Could you explain to me what it does?
    I was able to answer my own question only to find that it didn't quite work the way I need it to. I was able to make the logic work so that "if the time is 12AM then change the date for Time 1". However, I ran into another problem and realize that
    I ultimately just need to get this to work in one direction. Meaning I need it to find the difference in time STARTING from the Time 1 field TO the Time 2 field. Here's why (using the statement I got to work but only for 12AM):
    Time 1 | Time 2 | Time Difference (in minutes)
    23:45 | 1/15/2014 2:05:00 AM | -1300

  • I am having multiple issues with syncing my iphone calendar and outlook There are often 1 hour time differences in the entries on the 2 devices and sometimes events that have been amended are not updated on iphone I mostly enter items on my laptop

    I am having multiple issues with syncing my iphone calendar and outlook calendar on my laptop
    I mostly enter the original items on my laptop
    There are often 1 hour time differences in the entries on the 2 devices and sometimes events that have been amended are not updated on iphone

    This sounds like an error in Time Zone support. The time zone needs to be the same in Outlook as well as the phone.

  • I am having trouble transferring files from an old MacBook (2007) to a MacBook Air over a wireless network.  The connection was interrupted and the time was over 24 hours.  Is there a better way to do this?  I'm using Migration assistant.

    I am having trouble transferring files from an old MacBook (2007) to a MacBook Air over a wireless network.  The connection was interrupted and the time was over 24 hours.  Is there a better way to do this?  I'm using Migration assistant.  The lack of an ethernet port on MacBook air does not help.

    William ..
    Alternative data transfer methods suggested here > OS X: How to migrate data from another Mac using Mavericks

Maybe you are looking for

  • Installing Snow Leopard

    I recently updated my OS to Snow Leopard. It's running slow, so I'm gonna re-format my HD and run a clean install. Will I lose any of the Applications that came with the computer upon the Snow Leopard installation? Thanks, -Adam

  • DOCUMENT CLASSIFICATION AND CTXRULE INDEX TYPES IN ORACLE9I TEXT

    제품 : ORACLE SERVER 작성날짜 : 2004-05-27 DOCUMENT CLASSIFICATION AND CTXRULE INDEX TYPES IN ORACLE9I TEXT ================================================================ PURPOSE 이 문서는 Oracle9i 에서 추가된 새로운 기능으로 Oracle Text 에서의 문서 분류기능(Document Classificat

  • Split Partition - One to Many

    I have to split a single monthly partition (for month-end date) into daily partition for each day of the month. I am currently doing it one at a time, that is, by splitting one partition into two like 31st january into 31st January and 1st January. T

  • How do i delete apps on ios 7

    I am trying to make space on my phone but can not delete applications on my phone and i dont know why can anybody help!?!?!?!?!

  • Trouble adding CC software to current installation with CC Packager.

    I have done 3 packages.  First I did Photoshop, Acrobat, InDesign and Bridges. Then without restarting CC Packager I did Dreamweaver. I restarted the computer and after that I did Premiere Pro. Then I tried installing them, package 1 and 2 went fine