SQL required

Hi All
I have a table called file_seq havign the following field ID, S_TIME,SEQ_NO.
The sample is below:
ID S_TIME SEQ_NO
IJ_A1 01-AUG-10 1232
IJ_A2 01-AUG-10 1233
IJ_A3 01-AUG-10 1234
IJ_A4 01-AUG-10 1235
IJ_A5 01-AUG-10 1236
IJ_A6 01-AUG-10 1237
A1 01-AUG-10 1232
A2 01-AUG-10 1233
A3 01-AUG-10 1234
A4 01-AUG-10 1235
A6 01-AUG-10 1237
Here you can see the ID has two types one starts with IJ and other not having IJ, but the remaining is same.
I would like to compare those IDs with and without IJ and result will be the missing rows from any group.
Here the missing one is:
ID S_TIME SEQ_NO
A5 01-AUG-10 1236
Could you pelase suggest a SQL statement for this with self join method?
br
Abdunnasar

Hi Try this:
select id,s_time,seq_no
from file_seq
minus
select id,s_time,seq_no
from file_seq
where id in (select id from file_seq
                 where id like '%IJ%')
I think you could be more elaborative for this:I would like to compare those IDs with and without IJ and result will be the missing rows from any group.
Here the missing one is:
ID S_TIME SEQ_NO
What you like to compare with? the whole group with IJ and a whole group without IJ!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Stuck with this SQL requirement

    Ok here's the basic test data for my requirement:
    with test_data as
      select to_date('15/12/2008','dd/mm/yyyy') as start_date, to_date('15/12/3000','dd/mm/yyyy') as end_date from dual
    select *
    from test_data;
    START_DATE END_DATE
    15-12-2008 15-12-3000We work with a pattern, which is divided in two parts:
    The first week : the first 7 days of the pattern, starting from START_DATE
    The Second week : the 7 days that follow the first week (self explanatory)
    I've got a requirement that says that if I'm supplied with a date, I have to find out what pattern (first or second week) the supplied date falls in.
    so, our pattern for test_data is:
    15-12-2008 : First day of 1st week
    16-12-2008 : Second day of 1st week
    17-12-2008 : Third day of 1st week
    18-12-2008 : Fourth day of 1st week
    19-12-2008 : Fifth day of 1st week
    20-12-2008 : Sixth day of 1st week
    21-12-2008 : Seventh day of 1st week
    22-12-2008 : First day of second week
    23-12-2008 : Second day of second week
    28-12-2008 : Seventh day of second week
    ============================== end of pattern =================================
    29-12-2008 : Start of First day of 1st week
    Now, if my date supplied is 16 Dec 2008, my sql should return something like: "First Week".
    If my date supplied is 24-12-2008, my sql should return "Second week".
    If my date supplied is 29-12-2008, my sql should return "First Week".
    phew, I thought of a connect by, but this wouldn't do the trick I think because the comparison is between columns and no rows. No clue.. I could only got til using 16/12/2008 as test date, but it doesn't work in all cases :-(:
    with test_data as
      select to_date('15/12/2008','dd/mm/yyyy') as start_pattern, to_date('15/12/3000','dd/mm/yyyy') as end_pattern from dual
    select
           start_pattern,
           start_pattern + 7,
           case when to_date('16/12/2008','dd/mm/yyyy') between start_pattern and start_pattern + 7 then
               'first'
           else
               'second'
           end week_it_belongs_in_pattern
    from test_data
    START_PATT START_PATT WEEK_I
    15-12-2008 22-12-2008 firstEdited by: user9541973 on Nov 18, 2008 8:57 PM

    Solution
    SELECT X SO , PP PATERN
    FROM DUAL
    MODEL
    DIMENSION BY (TO_DATE(&DT1,'YYYY-MM-DD') X)
    MEASURES (1 Y, 'FIRST  WEEK' PP)
    (Y[FOR X FROM DATE  &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=0,
    PP[FOR X FROM DATE  &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=
       DECODE(MOD(CV(X)- TO_DATE(&DT1,'YYYY-MM-DD'),7),0,'First',1,'Second ',2,
                               'Third',3,'Fourth',4,'Fifth',5,'Sixth',6,'Seventh')||
                                ' day of '||
       CASE WHEN  MOD(TO_CHAR(CV(X),'IW'),2)= 1 THEN
        'first week'
        ELSE 'second week' END  )
    Demo
    SQL> SELECT X SO , PP PATERN
      2  FROM DUAL
      3  MODEL
      4  DIMENSION BY (TO_DATE(&DT1,'YYYY-MM-DD') X)
      5  MEASURES (1 Y, 'FIRST  WEEK' PP)
      6  (Y[FOR X FROM DATE  &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=0,
      7  PP[FOR X FROM DATE  &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=
      8     DECODE(MOD(CV(X)- TO_DATE(&DT1,'YYYY-MM-DD'),7),0,'First',1,'Second ',2,
      9                             'Third',3,'Fourth',4,'Fifth',5,'Sixth',6,'Seventh')||
    10                              ' day of '||
    11     CASE WHEN  MOD(TO_CHAR(CV(X),'IW'),2)= 1 THEN
    12      'first week'
    13      ELSE 'second week' END  );
    Entrez une valeur pour dt1 : '2008-12-15'
    ancien   4 : DIMENSION BY (TO_DATE(&DT1,'YYYY-MM-DD') X)
    nouveau   4 : DIMENSION BY (TO_DATE('2008-12-15','YYYY-MM-DD') X)
    Entrez une valeur pour dt1 : '2008-12-15'
    Entrez une valeur pour dt2 : '2009-02-15'
    ancien   6 : (Y[FOR X FROM DATE  &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=0,
    nouveau   6 : (Y[FOR X FROM DATE  '2008-12-15' TO DATE '2009-02-15' INCREMENT INTERVAL '1' DAY ]=0,
    Entrez une valeur pour dt1 : '2008-12-15'
    Entrez une valeur pour dt2 : '2009-02-15'
    ancien   7 : PP[FOR X FROM DATE  &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=
    nouveau   7 : PP[FOR X FROM DATE  '2008-12-15' TO DATE '2009-02-15' INCREMENT INTERVAL '1' DAY ]=
    Entrez une valeur pour dt1 : '2008-12-15'
    ancien   8 :    DECODE(MOD(CV(X)- TO_DATE(&DT1,'YYYY-MM-DD'),7),0,'First',1,'Second ',2,
    nouveau   8 :    DECODE(MOD(CV(X)- TO_DATE('2008-12-15','YYYY-MM-DD'),7),0,'First',1,'Second ',2,
    SO         PATERN
    2008-12-15 First day of first week
    2008-12-16 Second  day of first week
    2008-12-17 Third day of first week
    2008-12-18 Fourth day of first week
    2008-12-19 Fifth day of first week
    2008-12-20 Sixth day of first week
    2008-12-21 Seventh day of first week
    2008-12-22 First day of second week
    2008-12-23 Second  day of second week
    2008-12-24 Third day of second week
    2008-12-25 Fourth day of second week
    SO         PATERN
    2008-12-26 Fifth day of second week
    2008-12-27 Sixth day of second week
    2008-12-28 Seventh day of second week
    2008-12-29 First day of first week
    2008-12-30 Second  day of first week
    2008-12-31 Third day of first week
    2009-01-01 Fourth day of first week
    2009-01-02 Fifth day of first week
    2009-01-03 Sixth day of first week
    2009-01-04 Seventh day of first week
    2009-01-05 First day of second week
    SO         PATERN
    2009-01-06 Second  day of second week
    2009-01-07 Third day of second week
    2009-01-08 Fourth day of second week
    2009-01-09 Fifth day of second week
    2009-01-10 Sixth day of second week
    2009-01-11 Seventh day of second week
    2009-01-12 First day of first week
    2009-01-13 Second  day of first week
    2009-01-14 Third day of first week
    2009-01-15 Fourth day of first week
    2009-01-16 Fifth day of first week
    SO         PATERN
    2009-01-17 Sixth day of first week
    2009-01-18 Seventh day of first week
    2009-01-19 First day of second week
    2009-01-20 Second  day of second week
    2009-01-21 Third day of second week
    2009-01-22 Fourth day of second week
    2009-01-23 Fifth day of second week
    2009-01-24 Sixth day of second week
    2009-01-25 Seventh day of second week
    2009-01-26 First day of first week
    2009-01-27 Second  day of first week
    SO         PATERN
    2009-01-28 Third day of first week
    2009-01-29 Fourth day of first week
    2009-01-30 Fifth day of first week
    2009-01-31 Sixth day of first week
    2009-02-01 Seventh day of first week
    2009-02-02 First day of second week
    2009-02-03 Second  day of second week
    2009-02-04 Third day of second week
    2009-02-05 Fourth day of second week
    2009-02-06 Fifth day of second week
    2009-02-07 Sixth day of second week
    SO         PATERN
    2009-02-08 Seventh day of second week
    2009-02-09 First day of first week
    2009-02-10 Second  day of first week
    2009-02-11 Third day of first week
    2009-02-12 Fourth day of first week
    2009-02-13 Fifth day of first week
    2009-02-14 Sixth day of first week
    2009-02-15 Seventh day of first week
    63 ligne(s) sélectionnée(s).
    SQL>  Edited by: Salim11 on 2008-11-19 08:16
    Edited by: Salim11 on 2008-11-19 08:17
    Edited by: Salim11 on 2008-11-19 08:18

  • SQL requirements for WSUS 6 on WS2012?

    Hello.
    We are implementing a new WSUS deployment on WS2K12 - approximately 15K clients.
    The topology is one upstream (root) WSUS server, with 2 downstream WSUS (replica) servers.
    All 3 WSUS servers are virtual machines.
    The replica servers will use WID for the database.
    The root WSUS server could either use WID or SQL 2008 R2 SP1 cluster, I've read that SQL Express isn't recommended. 
    Questions -
    1) Any reason to choose the SQL cluster over WID for the root WSUS server?
    2) Does WSUS require a dedicated instance on the SQL cluster, or can it use the default instance (with about 50 databases currently)?
    Thank you.

    At what number of clients would we want to change from WID to the SQL cluster?
    The **ONLY** reason to use a back-end SQL Cluster is because you're so functionally dependent on the services of WSUS that you need to have three 9s of availability on the WSUS environment.
    But without deploying Fault Tolerance on the front-end, it's absolutely pointless to worry about using a cluster on the back end.
    Furthemore, while NLB + SQLCluster is one methodology for achieving fault tolerance, I believe there's a much simpler solution:
    Upstream Server + Multiple Replica Servers.
    A very specific feature enhancement was made to WSUS v3.0 in 2007 to allow ANY replica server to be reconfigured to an Upstream Server with only a few mouse clicks. If you really need fault tolerance, deploy a replica server with no clients as a hot standby
    in another site or datacenter. It's much cheaper, and exponentially easier to setup, configure, and maintain than an NLB+SQLCluster.
    And let's be real.... how many hours/days a month do you actually use the WSUS server? Are you in a position where having the WSUS server offline for a day or so would be catastrophic to the BUSINESS. (We're not talking about an inconvenience in deploying
    security updates, we're talking about actual Loss of Revenue due to the server being offline.)
    For almost every organization, the answer is Zero Impact. And if the answer is Zero Impact, this scenario is NOT a candidate for fault tolerance when you can achieve the same thing with just one more VM as a clientless replica server.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • Connect Enterprise - MS SQL Requirements

    Hello,
    I've looked through all the documentation I could find and
    also searched both the knowledgebase and the forum to find answers.
    What I'm looking for is granular "rule of thumb type data" for
    instance like in the format of:
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_19524&sliceId=2
    Anyway:
    1. Does anyone have general MS SQL database file size metrics
    in regard to Adobe Connect Enterprise? I know it's a tough question
    with many answers based on how large of an install, how many users,
    etc. However does anyone have metrics based on what they've
    experienced?
    2. I have seen the Adobe server requirements for a Connect
    install, however, what would be the server requirements for a
    second server used as a SQL server to support the Connect install?
    Regarding MS SQL server to support a Connect install, should I use
    the requirements for Adobe Connect as a rule of thumb or the MS SQL
    Server 2005 requirements instead?
    Thanks!

    1) The database file is tiny; the content is the larger
    storage hog and is stored in a file system. I believe the database
    on one of our installs is about 1 MB with over 1,000 users.
    2) We currently have it set up with SQL 2000, but have
    started discussing the migration to SQL 2005 on the database
    server. I would go with 2005 to start with just because it's one
    less migration, but I couldn't say based on experience.

  • Does the ODM using PL/SQL require the JVM?

    Does the database need to have the the Java Virtual Machine running in order to use the ODM PL/SQL calls?
    Is it true that $20k/cpu is required to use ODM?

    Using ODM PL/SQL api does not require JVM installed in the database.
    In 10.1 release, the installation of ODM product which included Java api and PL/SQL api requires JVM to be installed in the database. In 10.2 release, this requirement is no longer existed.
    For ODM license fee questions, please contact Oracle sales staff.
    Xiafang

  • R12 12.0.4 Onhand Quantity SQL required

    Hi guys
    We are a huge retailing company and currently in the process of implementing a custom made application for POS. One of our requirements is to reserve a given quantity against a particular item and once the PO received from the customer, raise a Credit invoice against customer account. Throughout last couple of years after the R12 implementation we kept on adding in-house built modules, mostly for tracking the on-hand quantities. We never used the material reservation until the custom application integration.
    As we are planning to go live with the custom built application, we are in a requirement to alter our on-hand quantity scripts throughout the custom modules and reports. Right now we are using the following query to fetch the on-hand quantities:
    Select onhand_quantity from
    Select sum(onhand_qty) onhand_quantity, inventory_item_id, organization_id, subinventory_code from
    Select sum(transaction_quantity) onhand_qty,inventory_item_id, organization_id, subinventory_code from mtl_onhand_quantities
    group by organization_id, subinventory_code, inventory_item_id
    union all
    Select sum(reservation_quantity)*-1 onhand_qty,inventory_item_id, organization_id, subinventory_code from mtl_reservations
    group by organization_id, subinventory_code, inventory_item_id
    group by inventory_item_id, organization_id, subinventory_code
    where inventory_item_id = :item_id and
    organization_id = :org_id and
    subinventory_code = :subinv_code
    Should we consider anything else? We tried to use "apps.INV_QUANTITY_TREE_PUB.QUERY_QUANTITIES" API, unfortunately while compiling we got compilation errors. Please forward your suggestions
    regards,

    Thanks Sandeep
    Unfortunately, we do use move orders quite frequent (OM team just confirmed) and there are just few entries in MTL_MATERIAL_TRANSACTION_TEMP table. A total of 6 records dating back to 2010.
    Anyway we are going ahead with the current setup and will include this table if differences are found at later stages. Thank you very much for your replies.
    Regards,

  • Lync 2013 SQL requirements

    I have a SQL environment which is used for web apps, ERP, CRM and other databases. Can I install my Lync SQL environment onto this SQL server? is this scenario supported?
     or do I need dedicated and separate Lync SQL servers?

    It's recommended to use a separate SQL server for Lync (Physical of Virtual), however collating Lync database with other SQL databases will work. Considering the cost of SQL licenses, this is not uncommon.
    It is important in either scenario that the SQL servers have adequate resources/performance to be able to handle the load from Lync server in addition to anything else it will be doing. 
    Also note that if you have multiple front end pools, these cannot share a SQL server. (and creating another instance on the same SQL server also does not work)
    Take a look at the Technet information for more: http://technet.microsoft.com/en-us/library/jj205112.aspx and http://technet.microsoft.com/en-us/library/gg398835.aspx
    (refer to Back End Servers)
    If this helped you please click "Vote As Helpful" if it answered your question please click "Mark As Answer"
    Georg Thomas | Lync MVP
    Blog www.lynced.com.au | Twitter
    @georgathomas
    Lync Edge Port Check (Beta)
    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Lync enterprise sql requirements

    Experts,
    Can i share another databases in SQL instance which hold the LYNC enterprise database, ?
    Ahmad Samir | MCSE 2003, MCSE 2012 Private Cloud | MCTS: SCOM 2007, Lync 2010, Exchange 2010, Server Virtualization.

    Yes you can collocate SQL with other databases but it is not recommended approach by MS
    check this
    https://technet.microsoft.com/en-us/library/gg398990(v=ocs.15).aspx
    Whenever you see a helpful reply, click on Vote As Helpful & click on Mark As Answer if a post answers your question.

  • Help ! SQL Required

    Hi Experts,
    Using the details below in the table ADV_TAB, I need to generate the Report in the following Output Format :
    CREATE TABLE ADV_TAB
    PID          VARCHAR2(3),
    NOB          VARCHAR2(8),
    AMOUNT          NUMBER(15,2),
    TARGET          NUMBER(15,2),
    PURPOSE          NUMBER(5),
    MPURPOSE     VARCHAR2(30),
    PURPOSETYPE     VARCHAR2(35),
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '10029ABR', 200000, 0, 706, 'AH', 'SPECIAL' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '10109ABR', 150000, 0, 706, 'AH', 'SPECIAL' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '10286ABR', 200000, 0, 706, 'AH', 'SPECIAL' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '10567ABR', 300000, 0, 706, 'AH', 'SPECIAL' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '10603ABR', 500000, 0, 10207, 'KC', 'KISAAN' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '10900ABR', 500000, 0, 10207, 'KC', 'KISAAN' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '11179ABR', 450000, 0, 501, 'TR', 'TRACTOR' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '11446ABR', 200000, 0, 706, 'AH', 'SPECIAL' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '14006ABR', 60000, 0, 105, 'MI', 'MINOR' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '16169ABR', 1075000, 0, 306, 'LD', 'LAND' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '16179ABR', 1100000, 0, 306, 'LD', 'LAND' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '16192ABR', 500000, 0, 8104, 'RH', 'HOUSING' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'ABR', '', 0, 88000000, 0, '', '' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'AJN', '10636AJN', 250000, 0, 10207, 'KC', 'KISAAN' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'AJN', '10636AJN', 300000, 0, 306, 'LD', 'LAND' );
    INSERT INTO ADV_TAB ( PID, NOB, AMOUNT, TARGET, PURPOSE, MPURPOSE, PURPOSETYPE) VALUES ( 'AJN', '', 0, 39400000, 0, '', '' );
    OUTPUT FORMAT :
                     SPECIAL             KISAAN             TRACTOR            MINOR                  LAND               HOUSING            TOTAL          
    PID     TARGET          NOB     AMOUNT          NOB     AMOUNT          NOB     AMOUNT          NOB     AMOUNT          NOB     AMOUNT        NOB   AMOUNT          NOB     AMOUNT     
    ABR     88000000     5     1050000          2     1000000          1     450000          1     200000          1     60000        2      2175000     13     5435000
    AJN     39400000     0     0          1     2500000          0     0          0     0          1     300000        0      0          2     550000
    TOTAL->                                                                                                                                                      Can the above Report Format be generated using plain SQL ?

    Hi,
    this is a pivoting problem.
    Have you already checked in the FAQ: [url:https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360005]4. How do I convert rows to columns?
    It should be helpful also to mention which database version are you using to understand if it 11g PIVOT function can be used.
    Could you also tell me what you expect in the output for the row starting with
    TOTAL->     Regards.
    Al

  • Help in SQL required

    Please find the below query I am getting
    Revenue and cost I have to calculate GP and GP%
    Details Value
    Revenue 100
    Cost 50
    Gross Profit (Revenue-Cost)
    Gross Profit % ((Revenue-Cost)/Revenue)*100
    -- query for GM details drill down page (at service line level)--
    select Details as "Details",
    round(sum(Ons_value),0) as "Onsite",
    round(sum(Off_value),0) as "Offshore",
    round(sum(Total),0) as "Total",
    sum(Ons_value) as "Onsite Calc",
    sum(Off_value) as "Offshore Calc",
    sum(Total) as "Total Calc"
    from(
    -- Revenue
    select 'Revenue' as Details,
    decode(c.bU_TYPE, 'F' ,c.usd_amt/1000) as Off_value,
    decode(c.bU_TYPE, 'O' ,c.usd_amt/1000) as Ons_value,
    c.usd_amt/1000 as Total
    from CHART_ACCT_REFERENCE b,
    DSS_PRJ_REV_F c,
    DSS_CHART_ACCT_D d,
    dss_period_d e
    where
    e.cal_id='FYIND'
    AND e.fy_year=2007
    AND (E.FY_QTR = 'ALL' OR 'ALL'= 'ALL')
    and (e.MONTH_NAME ='AUGUST' OR 'ALL'= 'ALL')
    and e.trans_dt <=to_date('8/1/2007','MM/DD/YYYY')
    and c.TRANS_DT=e.TRANS_DT
    AND C.ACCT_TYPE='RC'
    AND c.DSS_ACCT_KEY= d.DSS_ACCT_KEY
    and d.ACCT_NBR=b.ACCT_NBR
    and b.TYPE='REVENUE'
    AND C.DSS_DEL_SERVC_LN_KEY IN( SELECT DSS_DEL_SERVC_LN_KEY FROM DSS_DEL_SERVC_LN_D WHERE DSS_SERVC_LN_ID='800')
    union all
    -- Direct Cost
    select 'Direct Cost' as Details,
    decode(c.bU_TYPE, 'F' ,-c.usd_amt/1000) as Off_value,
    decode(c.bU_TYPE, 'O' ,-c.usd_amt/1000) as Ons_value,
    -c.usd_amt/1000 as Total
    from CHART_ACCT_REFERENCE b,
    DSS_PRJ_REV_F c,
    DSS_CHART_ACCT_D d,
    dss_period_d e
    where
    e.cal_id='FYIND'
    AND e.fy_year=2007
    AND (E.FY_QTR = 'ALL' OR 'ALL'= 'ALL')
    and (e.MONTH_NAME ='APRIL' OR 'ALL'= 'ALL')
    and e.trans_dt <=to_date('8/1/2007','MM/DD/YYYY')
    and c.TRANS_DT=e.TRANS_DT
    AND C.ACCT_TYPE='RC'
    AND c.DSS_ACCT_KEY= d.DSS_ACCT_KEY
    and d.ACCT_NBR=b.ACCT_NBR
    and b.TYPE='COST'
    AND C.DSS_DEL_SERVC_LN_KEY IN( SELECT DSS_DEL_SERVC_LN_KEY FROM DSS_DEL_SERVC_LN_D WHERE DSS_SERVC_LN_ID='800')
    group by Details
    Please help me
    Thanks
    Aashee

    I don't have the data to do any testing but if you have 10g with analytical functions you could do something along these lines perhaps (If I've understood what the output is going to be from your existing query)...
    SELECT details, onsite, offshore, total, onsite_calc, offshore_calc, total_calc
          ,MAX(revenue) over (order by 1) - Max(d_cost) over (order by 1) as gross_profit
          ,ROUND(((MAX(revenue) over (order by 1) - Max(d_cost) over (order by 1))/MAX(revenue) over (order by 1))*100,2) as gross_profit_perc
    FROM (
    SELECT   details AS Details
           , ROUND (SUM (ons_value), 0) AS Onsite
           , ROUND (SUM (off_value), 0) AS Offshore
           , ROUND (SUM (total), 0) AS Total
           , SUM (ons_value) AS Onsite_Calc
           , SUM (off_value) AS Offshore_Calc
           , SUM (total) AS Total_Calc
           , DECODE(details, 'Revenue', total) as revenue
           , DECODE(details, 'Direct Cost', total) as d_cost
        FROM (
    -- Revenue
              SELECT 'Revenue' AS details, DECODE (c.bu_type, 'F', c.usd_amt / 1000) AS off_value, DECODE (c.bu_type, 'O', c.usd_amt / 1000) AS ons_value, c.usd_amt / 1000 AS total
                FROM chart_acct_reference b, dss_prj_rev_f c, dss_chart_acct_d d, dss_period_d e
               WHERE e.cal_id = 'FYIND'
                 AND e.fy_year = 2007
                 AND (e.fy_qtr = 'ALL' OR 'ALL' = 'ALL')
                 AND (e.month_name = 'AUGUST' OR 'ALL' = 'ALL')
                 AND e.trans_dt <= TO_DATE ('8/1/2007', 'MM/DD/YYYY')
                 AND c.trans_dt = e.trans_dt
                 AND c.acct_type = 'RC'
                 AND c.dss_acct_key = d.dss_acct_key
                 AND d.acct_nbr = b.acct_nbr
                 AND b.TYPE = 'REVENUE'
                 AND c.dss_del_servc_ln_key IN (SELECT dss_del_servc_ln_key
                                                  FROM dss_del_servc_ln_d
                                                 WHERE dss_servc_ln_id = '800')
              UNION ALL
    -- Direct Cost
              SELECT 'Direct Cost' AS details, DECODE (c.bu_type, 'F', -c.usd_amt / 1000) AS off_value, DECODE (c.bu_type, 'O', -c.usd_amt / 1000) AS ons_value, -c.usd_amt / 1000 AS total
                FROM chart_acct_reference b, dss_prj_rev_f c, dss_chart_acct_d d, dss_period_d e
               WHERE e.cal_id = 'FYIND'
                 AND e.fy_year = 2007
                 AND (e.fy_qtr = 'ALL' OR 'ALL' = 'ALL')
                 AND (e.month_name = 'APRIL' OR 'ALL' = 'ALL')
                 AND e.trans_dt <= TO_DATE ('8/1/2007', 'MM/DD/YYYY')
                 AND c.trans_dt = e.trans_dt
                 AND c.acct_type = 'RC'
                 AND c.dss_acct_key = d.dss_acct_key
                 AND d.acct_nbr = b.acct_nbr
                 AND b.TYPE = 'COST'
                 AND c.dss_del_servc_ln_key IN (SELECT dss_del_servc_ln_key
                                                  FROM dss_del_servc_ln_d
                                                 WHERE dss_servc_ln_id = '800'))
    GROUP BY details
    )This assumes that your existing query outputs two rows of data, one for Revenue and it's totals and the other for Direct Cost and it's totals. The trick is to get the total values from each row and use them together to display the Gross Profit information, which you can do using analytical functions to obtain the data from the other row. Of course the figures will appear duplicated on both rows, but you haven't specified anything different.
    Message was edited by:
    BluShadow

  • List of sql services required for deployment server?

    What are the role of list of sql services in case of BizTalk, like notification service is required for BAM.
    Along with can any one let me know the minimum services of SQL required on production.
    1.Database Engine Services
     SQL Server Replication
      Full-Text Search
    2.Analysis Services
    3.Reporting Services
    4.Shared Features
     Business Intelligence Development Studio
     Client Tools Connectivity
     Integration Services
     Management Tools – Basic
    Is it mandatory to install  analysis, integration services on production server.
    Please suggest!
    Fred

    Sorry, that is not correct.  SQL components beyond Database Services are required in most circumstances.
    It's important you understand what to install based on your application requirements.
    The definitive guides can be found here:
    BizTalk Server 2009:
    http://www.microsoft.com/en-us/download/details.aspx?id=4066
    BizTalk Server 2010:
    http://msdn.microsoft.com/en-us/library/aa561167.aspx
    BizTalk Server 2013:
    http://msdn.microsoft.com/en-us/library/jj248688(v=bts.80).aspx
    As a matter of practice, I always install all BizTalk realted SQL Server features, even if they are not used.  This is for consistency across environments, reliable patching and to accomodate any future BizTalk app features.

  • Using multiple 'and' conditions in a SQL query

    Is it possible to reduce the SQL required to query using multiple 'and' conditions, e.g. I have a query like the following:
    select stat.personal_id, appt.username, appt.password, apps.rgn_apt_id, apps.apy_apn_id
    from apy_ast_application_status stat, rgn_usr_user appt, rgn_aps_applications apps
    where stat.apy_apn_id = apps.rgn_apt_id
    and apps.rgn_apt_id = appt.rgn_apt_id
    and stat.application_completed is null
    and stat.application_started_date > '01-MAY-11'
    and stat.amount_paid is null
    and stat.personal_details = 'C'
    and stat.further_details = 'C'
    and stat.education = 'C'
    and stat.employment = 'C'
    and stat.personal_statement = 'C'
    and stat.choices = 'C'
    and stat.reference = 'C'
    and stat.student_finance = 'C'
    Is there a way, to reduce all the multiple 'and' queries, to be read from say one line? If you know what I mean.......

    Ah, Ok this looks nice, thanks very much. It doesn't quite run as is because the stat.amount_paid query value is 'is null', while the others are 'C'. I tried amending the relevant line to various versions of the following:-
    in (select 'is null' 'C','C','C','C','C','C','C','C' from dual)
    which doesn't work.
    I can get the following to work so I am assuming that the it is not possible to use different query values within the brackets of the 'in (select....' statement?
    select stat.personal_id, appt.username, appt.password, apps.rgn_apt_id, apps.apy_apn_id
    from apy_ast_application_status stat, rgn_usr_user appt, rgn_aps_applications apps
    where stat.apy_apn_id = apps.rgn_apt_id
    and apps.rgn_apt_id = appt.rgn_apt_id
    and stat.application_completed is null
    and stat.application_started_date > '01-MAY-11'
    and stat.amount_paid is null
    and (stat.personal_details, stat.further_details, stat.education,
    stat.employment, stat.personal_statement, stat.choices, stat.reference, stat.student_finance)
    in (select 'C','C','C','C','C','C','C','C' from dual)
    Thanks for everybodys help - the suggested alternatives seem so much more elegant

  • Creating PL/SQL function in SQL plus which will display desired output

    Hello PL/SQL experts,
    I am not skilled on PL/SQL so want you help for one of the PL/SQL requirement.
    Requirement: We have a database purge jobs which deletes the records from our application database on daily basis. Our Client wants a verification PL/SQL to be created which they will run pre and post the purge job to identify the number of records deleted/processed by purge job. It should do a SELECT operation and find out the number of records in table based on the where clause and give the output to the user.
    The result of PL/SQL should be something like this (considering the PL/SQL is processing multiple select statements):
    ****Verification SQL Start*****
    30 records from table S_SRV_REQUEST selected
    45 records from table S_SRV_REQUEST_X selected
    15 records from table S_SRV_REQUEST_XM selected
    *****Verification SQL complete*****
    For this I am thinking of a simple PL/SQL which will diplay the count of records from each table but I am not sure how to display the count on screen as an output. Can I request PL/SQL experts to put some light on this?
    Regards
    Sumit

    PL/SQL is a server side process running on your database server.  It is not connected to a display or a keyboard, so cannot output any results from within the code itself.
    What you need is a client application that the user can run which will query the database, or call procedure(s) to get results and then the client application will display those results appropriately.
    One of the simplest client tools you can use to build such a user-friendly application is Oracle Application Express (APEX).
    Bear in mind that if you're going to 'identify' record for deletion prior to actually deleting them, then you may also have a need to store the keys of those identified records somewhere so that only those records are deleted.  Consider the situation where the user requests the information and the application queries the records to say there are 30 records from S_SRV_REQUEST with the correct criteria to be deleted.  By the time the user confirms they are happy and want the records deleted, some other record(s) may have been updated and also meet the criteria, so just doing a delete based on the criteria itself could result in more than 30 records being deleted.  However if you've identified the records and marked them in some way for deletion or stored the keys of those records on a queue somewhere to indicate the ones to be deleted, then your actual deletion process can just deal with those records and ignore any that have met the criteria since that time.  Of course that depends on your individual requirements, but it's something to bear in mind.

  • Using substitution variable in sql -- Issue

    Hello All
    I am trying to do a sql operation from command prompt of my system and that sql requires substitution variable which i am passing it but when i pass the variable ( there are two) the first one assign as " \c" and second gets both what i am passing.
    I am not sure what exactly happening here, i have done this on AIX but here its not working any ideas?
    System : uname -a
    Linux ## 2.6.18-128.1.1.el5 #1 SMP Mon Jan 26 13:58:24 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

    AIX and Linux are not the same. An output of "\c" may indicate a compatibility issue of your shell script with your current command line interpreter (shell). A \c can be used to suppress a newline with the echo command. Bash understands both formats echo -n and echo \c, but other shells like Ksh don't. Try to run your script under a Bash, which is the default under Linux. If the problem persists you will need to post your script for any further analysis.

  • Does 1Z0-001 fit the requirement of 11g DB OCP requirement (1Z0-051)?

    Dear Sir:
       Hi, I would like to ask 3 questions about the certification requirement of 11g DB OCP.
    Please advice me what do I have to do to prepare the OCP exam, thanks a lot in advance.
    Q1:
    Does 1Z0-001 fit the requirement of 11g DB OCP requirement (pass 1Z0-001 = pass 1Z0-051)?
    AFAIK, 11g DB OCP requires passing 3 exams: 1Z0-051 (SQL), 1Z0-052 (AW1), 1Z0-053 (AW2) and finishing a hand-on course at least.
    I have passed the 1Z0-001 (Introduction to SQL ans PL/SQL) many years ago.
    After searching the discussion in the community, I've found 2 relative:
    https://forums.oracle.com/thread/2526631  It said :"1Z0-001 will satisfy the SQL requirement."
    https://forums.oracle.com/thread/2467872 It said : "I can confirm that the 001 exam will fulfill the SQL exam requirement if it was passed before it retired."
    I was confused on that. Please help me to clear it.
    Do I have to prepare the exam 1Z0-051 since I have passed 1Z0-001 (an retired exam)?
    Q2:
    Please confirm that finishing the SSC (Self-Study Course) DOES NOT apply the "hand-on course requirement ".
    It still need to pay more money for an instructor-led (face-to-face) course, right?
    Q3:
    Can I just finish ONE course "Oracle 11g Database Administrator Workshop II" from an Oracle authorized education center to fit the " hand-on course requirement " ?
    Sorry I have to ask this because the budget consideration.
    Thank you very much!
    Steve C.

    Q1:
    Does 1Z0-001 fit the requirement of 11g DB OCP requirement (pass 1Z0-001 = pass 1Z0-051)?
    Q2:
    Please confirm that finishing the SSC (Self-Study Course) DOES NOT apply the "hand-on course requirement ".
    Q3:
    Can I just finish ONE course "Oracle 11g Database Administrator Workshop II" from an Oracle authorized education center to fit the " hand-on course requirement " ?
    A1 -- Yes, if you passed 1Z0-001, you do not need to take 1Z0-051.  When courses are retired, it simply means they are no longer given to *new* students.  Anyone who passed them still retains credit for having done so.
    A2 -- Self Study CDs do not count for the hands-in requirement.  On the approved courses page of OU, it specifically states: "Self Study CD-Rom and Knowledge Center courses are excellent study and reference tools but DO NOT meet the Hands-on Requirement for certification."
    A3 -- Only one course is required for the 11G OCP.  That one is on the approved list and so will be acceptable if the vendor is authorized by OU.

Maybe you are looking for

  • How can I delete cookies by date?

    I've been using Firefox for a hundred years, and have 550 gazillion cookies. I like cookies. (I'm an affiliate marketer and people who advise my customers to delete their cookies drive me nuts.) I'd like to delete cookies > 5 years old. How can I do

  • How can I transfer all my files from iphone 3g to iphone 4s?

    I have my iphone 3g with all the apps , contacts, emails, etc. (all the files). Then now I bought the iphone 4s and I want to transfer all my files and apps from iphone 3g to iphone 4s. Is there an easy way to transfer them?

  • Selecting a group of Images? only last image getting adjustments?

    sorry if this is a stupid question, but when I select a range of images and apply image rotation or stamp metadata, only the last image in the selection gets the adjustment that I apply to the images. It seems that when I select the images, the whole

  • Deployment error in ejb program

    I tried to deploy the ejb as said in tutorial and samples in C:\bea\weblogic81\workshop\help\doc\en\core\index.html But at the last stage ie,during deployment, I am getting this error [Deployment failed:149034]An exception occured for task [Deployer:

  • Imac help

    hey i just have a few questions about the purchasing part of the imac intel core duo, i cant find any canadian refurbished imac intel core duo's 17'' 1.83 ghz but with 1 gig of ram, 160gig hard drive and bootcamp pre installed with xp home,, even if