Query Help required

HI Experts ,
Could you please help me in getting below output ,
My Input Table :
Number
Loc_A
LOC_B
PARENT_NUMBER
A-01
Ind
Aus
A
A-02
Fra
NZ
A
A-03
Ind
SL
A
A-04
USA
Aus
A
A-05
Pak
WI
A
A-06
Fra
Ag
A
A-07
Rus
Ban
A
A-08
SA
Ind
A
A-09
Ind
Ind
A
My Required Output
Number
Loc_A
LOC_B
PARENT_NUMBER
A-01
Ind
Aus
A
A-02
Fra
NZ
A
A-03
Ind
SL
null
A-04
USA
Aus
null
A-05
Pak
WI
A
A-06
Fra
Ag
null
A-07
Rus
Ban
A
A-08
SA
Ind
A
A-09
Ind
Ind
null
I am comparing each and every record with its previous rows values for column Loc_A and Loc_B and if they are getting matched i m inserting null .
table structure
with t as
(select 'A-01' as Num,'Ind' as Loc_A,'Aus' as Loc_B,'A' as Parent_Num from dual
union all
select 'A-02' as Num,'Fra' as Loc_A,'NZ' as Loc_B,'A' as Parent_Num from dual
Union all
select 'A-03' as Num,'Ind' as Loc_A,'SL' as Loc_B,'A' as Parent_Num from dual
union all
select 'A-04' as Num,'USA' as Loc_A,'Aus' as Loc_B,'A' as Parent_Num from dual
union all
select 'A-05' as Num,'Pak' as Loc_A,'WI' as Loc_B,'A' as Parent_Num from dual
union all
select 'A-06' as Num,'Fra' as Loc_A,'Ag' as Loc_B,'A' as Parent_Num from dual
union all
select 'A-07' as Num,'Rus' as Loc_A,'Ban' as Loc_B,'A' as Parent_Num from dual
union all
select 'A-08' as Num,'SA' as Loc_A,'Ind' as Loc_B,'A' as Parent_Num from dual
union all
select 'A-09' as Num,'Ind' as Loc_A,'Ind' as Loc_B,'A' as Parent_Num from dual
select * from t;
Could you please help ,i have 1000's of rows with this kind of data

Hi,
I have tried to create a query, this might help you
WITH t AS (SELECT 'A-01' AS Num,
                  'Ind' AS Loc_A,
                  'Aus' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL
           UNION ALL
           SELECT 'A-02' AS Num,
                  'Fra' AS Loc_A,
                  'NZ' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL
           UNION ALL
           SELECT 'A-03' AS Num,
                  'Ind' AS Loc_A,
                  'SL' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL
           UNION ALL
           SELECT 'A-04' AS Num,
                  'USA' AS Loc_A,
                  'Aus' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL
           UNION ALL
           SELECT 'A-05' AS Num,
                  'Pak' AS Loc_A,
                  'WI' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL
           UNION ALL
           SELECT 'A-06' AS Num,
                  'Ind' AS Loc_A,
                  'Ag' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL
           UNION ALL
           SELECT 'A-07' AS Num,
                  'Rus' AS Loc_A,
                  'Ban' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL
           UNION ALL
           SELECT 'A-08' AS Num,
                  'SA' AS Loc_A,
                  'Ind' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL
           UNION ALL
           SELECT 'A-09' AS Num,
                  'Ind' AS Loc_A,
                  'Ind' AS Loc_B,
                  'A' AS Parent_Num
             FROM DUAL)
SELECT t.num,
       t.loc_a,
       t.loc_b,
       CASE
          WHEN (FIRST_VALUE (LOC_A)
                   OVER (ORDER BY NUM RANGE UNBOUNDED PRECEDING)) IN
                     (LOC_A, LOC_B)
                OR (FIRST_VALUE (LOC_B)
                     OVER (ORDER BY NUM RANGE UNBOUNDED PRECEDING)) IN
                     (LOC_A, LOC_B)
          THEN
          ELSE
             t.parent_num
       END
          parent_num
  FROM t
NUM
LOC_A
LOC_B
PARENT_NUM
A-01
Ind
Aus
A-02
Fra
NZ
A
A-03
Ind
SL
A-04
USA
Aus
A-05
Pak
WI
A
A-06
Ind
Ag
A-07
Rus
Ban
A
A-08
SA
Ind
A-09
Ind
Ind
Only error I have here is the First Value is showing '-'. I have not got enough time to remove it.
Regards,
Adarsh

Similar Messages

  • Query Help required to Connect JDT1 with OINV tables

    Dear Experts,
    I have the following query which gives me the customer ageing report. I want some addtional fields from the OINV table and the document numbering table like Document Series Name, AR Invoice document Number,AR invoice remarks, BP Projects Number ( filled in accounting tab in BP projects) and in the query in Reference 1 column its giving the Invoice Numbers as posted in the Journal but for manual Journal Entries it not giving the Journal Number which I also want to be shown in Ref 1 or a seperat field.
    The Query is as under :
    select OCRD.cardcode 'Supplier Code',OCRD.cardname 'Name',sysdeb 'Debit Amount',syscred 'Credit Amount',
    case JDT1.transtype
    when '13' then 'INV'
    when '14' then 'AR CN'
    when '24' then 'INCOMING'
    else 'Other'
    end 'Type',
    Ref1,
    fccurrency 'BP Currency',
    CONVERT(VARCHAR(10), refdate, 103)'Posting Date' ,
    CONVERT(VARCHAR(10), duedate, 103) 'Due Date',
    CONVERT(VARCHAR(10), taxdate, 103) 'Doc Date' ,
    CASE
    when (DATEDIFF(dd,refdate,current_timestamp))+1 < 31
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "0-30 days",
    case when ((datediff(dd,refdate,current_timestamp))+1 > 30
    and (datediff(dd,refdate,current_timestamp))+1< 61)
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "31 to 60 days",
    case when ((datediff(dd,refdate,current_timestamp))+1 > 60
    and (datediff(dd,refdate,current_timestamp))+1< 91)
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "61 to 90 days",
    CASE
    when (DATEDIFF(dd,refdate,current_timestamp))+1 > 90
    then
    case
    when syscred= 0 then sysdeb
    when sysdeb= 0 then syscred * - 1
    end
    end "90 + days"
    from JDT1,OCRD where JDT1.shortname = OCRD.cardcode and cardtype = 'c' and intrnmatch = '0'
    ORDER BY OCRD.CARDCODE, taxdate
    Would appreciate if you can help me to get a solution in it.
    Regards,
    Kamlesh

    Dear Gordon,
    While executing the followings modified query it giving an error of
    Incorrect Syntax near the keyword 'to' and incorrect Syntax near 'Series'
    the query is as under :
    {select OCRD.cardcode 'Supplier Code',OCRD.cardname 'Name',sysdeb 'Debit Amount',syscred 'Credit Amount',
    case l.transtype
    when '13' then 'INV'
    when '14' then 'AR CN'
    when '24' then 'INCOMING'
    else 'Other'
    end 'Type',
    j.BaseRef'Trans #',
    case l.transtype
    when '13' then
    (Select Comments from OINV where OINV.Transid=j.Transid)
    else '-'
    end 'Inv.Rem.',
    (Select SeriesName From NNM1 Where Series=j.DocSeries and ObjectCode=l.TransType)'Series',
    to
    (Select Isnull(SeriesName, 'Manual') From NNM1 Where Series=j.DocSeries and ObjectCode=l.TransType)'Series',
    l.Ref1,
    fccurrency 'BP Currency',
    CONVERT(VARCHAR(10), l.refdate, 103)'Posting Date' ,
    CONVERT(VARCHAR(10), l.duedate, 103) 'Due Date',
    CONVERT(VARCHAR(10), l.taxdate, 103) 'Doc Date' ,
    CASE
    when (DATEDIFF(dd,l.refdate,current_timestamp))+1 < 31
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "0-30 days",
    case when ((datediff(dd,l.refdate,current_timestamp))+1 > 30
    and (datediff(dd,l.refdate,current_timestamp))+1< 61)
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "31 to 60 days",
    case when ((datediff(dd,l.refdate,current_timestamp))+1 > 60
    and (datediff(dd,l.refdate,current_timestamp))+1< 91)
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "61 to 90 days",
    CASE
    when (DATEDIFF(dd,l.refdate,current_timestamp))+1 > 90
    then
    case
    when syscred= 0 then sysdeb
    when sysdeb= 0 then syscred * - 1
    end
    end "90 + days"
    from JDT1 l
    Inner Join OJDT j On j.TransId=l.TransId
    ,OCRD where l.shortname = OCRD.cardcode and cardtype = 'c' and intrnmatch = '0'
    ORDER BY OCRD.CARDCODE, l.taxdate}
    Regards,
    Kamlesh

  • Query help required to link two fields

    Hi all,
    I have made an query as under :
    SELECT T2.Period, T0.dept, T0.empID, T0.firstName, T0.lastName, T1.U_ebasic, T1.U_ehra, T1.U_etrspt, T1.U_ecola, T1.U_emeins, T1.U_education, T1.U_grosssal,T1.U_totduc, T1.U_oadd, T1.U_netsal, T1.U_bank, T1.U_branch, T1.U_accno FROM OHEM T0 , [dbo].[@PAYROLL_PR_DETAIL]  T1, [dbo].[@PAYROLL_PROLL_HEAD]  T2 where t2.docentry=t1.docentry and t1.U_ecode=t0.empid
    Now I want that the Department Full NAME as mentioned in the Human Resource screen for that employee should come. Apart from it I also want to link a new field in this query user_code from OUSR table for each employee.
    Can you please help me to make this query.
    Regards,
    kamlesh

    Dear Gordon,
    After rectifiying the spelling mistake I used the following query as under
    SELECT T2.Period, T0.dept, T3.Name, T0.empID, T0.firstName, T0.lastName, T4.USER_CODE,T1.U_ebasic, T1.U_ehra, T1.U_etrspt, T1.U_ecola, T1.U_emeins, T1.U_education, T1.U_grosssal,T1.U_totduc, T1.U_oadd, T1.U_netsal, T1.U_bank, T1.U_branch, T1.U_accno
    FROM dbo.OHEM T0
    INNER JOIN dbo.OUDP T3 ON T3.Code = T0.dept
    INNER JOIN dbo.OUSR T4 ON T4.INTERNAL_K = T0.userId
    INNER JOIN dbo.@PAYROLL_PR_DETAIL T1 ON t1.U_ecode=t0.empid
    INNER JOIN dbo.@PAYROLL_PROLL_HEAD T2 ON t2.docentry=t1.docentry
    but now the syntax error is coming as - 'Incorrect syntax near '@PAYROLL_PR_DETAIL'
    (SEWSY) (s) could not be prepared
    Please guide.
    Regards,
    Kamlesh

  • Help required in refining a query

    I have a sql query :
    select C1 AS No_Of_Completed_WOs, C2 as Wos_with_Soft_Fail, (C1-C2) as Completed_Wos,C3 as Failed_Wos,C4 as TimedOut_Wos from (select (CASE WHEN TBL_WRK_ORD.EXTSYS_ID IS NULL THEN '<NULL>'
    ELSE TBL_WRK_ORD.EXTSYS_ID END),
    count(case when WO_STAT=104 AND XACTION_TYPE like '%Completion%' then WO_STAT end ) as C1,
    count(case when WO_STAT=104 AND XACTION_TYPE like '%Soft Error%' then WO_STAT end ) AS C2,
    count(case when WO_STAT=253 then WO_STAT end ) AS C3,
    count(case when WO_STAT=251 then WO_STAT end ) AS C4
    from TBL_WRK_ORD,TBL_WO_EVENT_QUEUE WHERE TBL_WRK_ORD.WO_ID=TBL_WO_EVENT_QUEUE.WO_ID group by TBL_WRK_ORD.EXTSYS_ID)
    The query basically maintains a separate counter for each of the qualifying condition.
    C1 : if the WO_STAT is 104 and XACTION_TYPE is '%Completion%'
    C2 : if the WO_STAT is 104 and XACTION_TYPE is '%Soft Error%'
    C3 : if the WO_STAT is 253
    C4 : if the WO_STAT is 251.
    Now, the requirement is that we need to fetch distinct records, based on which the summation will be carried upon.
    I was not able to incorporate the "distinct" logic in the above query.
    Required help in this regards, as how to fetch distinct records and use it in the summation logic.
    A quick help would be appreciated and thankful.
    Regards
    RAT.
    Edited by: user9546298 on Feb 24, 2010 6:36 AM
    Edited by: user9546298 on Feb 24, 2010 7:06 AM

    Here is the sample data :
    {code }
    Table : TBL_WRK_ORD
    WO_ID SCHED_DTS WO_STAT
    EXTSYS_ID
    A00000001-QRY_ISUP_SERVICE_L 20091126 03:28:02 103
    MRK
    A00000002-S3 20091201 02:42:34 255
    MRK
    A00000003-A4 20091201 02:50:28 253
    A00000006-ADD1 20091202 05:37:45 104
    A00000004-ADD1 20091201 03:40:39 104
    A00000005-DNH1 20091202 05:12:06 253
    6 rows selected.
    Table : TBL_WO_EVENT_QUEUE
    WO_ID XACTION_TYPE
    A00000001-QRY_ISUP_SERVICE_L WO Accept
    A00000001-QRY_ISUP_SERVICE_L WO Startup
    A00000001-QRY_ISUP_SERVICE_L WO Completion
    A00000002-S3 WO Accept
    A00000003-A4 WO Accept
    A00000003-A4 WO Startup
    A00000003-A4 WO Rollback
    A00000003-A4 WO Failure
    A00000005-DNH1 WO Rollback
    A00000005-DNH1 WO Failure
    A00000006-ADD1 WO Accept
    A00000006-ADD1 WO Startup
    A00000004-ADD1 WO Accept
    A00000004-ADD1 WO Startup
    A00000004-ADD1 WO Completion
    A00000005-DNH1 WO Accept
    A00000005-DNH1 WO Startup
    A00000006-ADD1 WO Completion
    Current output :
    NO_OF_COMPLETED_WOS WOS_WITH_SOFT_FAIL COMPLETED_WOS FAILED_WOS TIMEDOUT_WOS
    2 0 2 8 0
    0 0 0 0 0
    Here, as you can see above that the result has duplicates, which caused the counters to show wrong result.
    Now, the query should filter based on given criteria and produce the count of the filtered rows.
    But doing so, should consider distinct rows for counting.
    Also, just placing distinct at counting logic [ pasted by you ] didnot work. I tried it out, but in vain.
    Regards
    RAT.
    Edited by: user9546298 on Feb 24, 2010 7:09 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Urgent help required: Query regarding LC Variables

    Hi All
    Sometime earlier I was working on a performance issue raised by a customer. It was shell script that was taking almost 8-9 hrs to complete. During my research I came across a fact that there were some variables which were not set, the LC variables were impacting the sort funnel operations because of which the script was taking a long time to execute.
    I asked them to export the following commands, after which the program went on smoothly and finished in a couple of mins:
    export LC_COLLATE=en_US.ISO8859-1
    export LC_MESSAGES=C
    export LC_MONETARY=en_US.ISO8859-1
    export LC_MONETARY=en_US.ISO8859-1
    export HZ=100
    export LC_CTYPE=en_US.ISO8859-1
    export LANG=en_US.UTF-8
    Later I did recover that setting the LC_COLLATE to C, is not helping and the program was again taking a lot of time. Few questions that I want to ask are:
    1. Can someone please tell me, what each of these variable mean and how these values make a difference.
    2. When I exported LC_COLLATE=en_US.ISO8859-1, it worked fine, but when i tried with the defalut value LC_COLLATE=C, then why the program didnt work.
    As this issue is still going on, hence I would request All to provide their valuable inputs and let me know as much as possible.
    Appreciate your help in this regard.
    Thanks
    Amit
    Hi All
    A new development in this regard. The customer has send us a screen shot in which they were trying to export the locale variable using the commands which I have pasted above. I can see in the screen shot that while exporting LC_COLLATE and LC_TYPE, they get a message that ""ksh: export: couldn't set locale correctly"".
    Request everyone to please give their inputs as it's a bit urgent.
    Thanks for all the help in advance.
    Thanks
    Amit
    Some help required please...
    Edited by: amitsinhaengg on Jul 22, 2009 2:03 AM
    Edited by: amitsinhaengg on Jul 22, 2009 2:06 AM

    LC_CTYPE
    Controls the behavior of character handling functions.
    LC_TIME
    Specifies date and time formats, including month names, days of the week, and common full and abbreviated representations.
    LC_MONETARY
    Specifies monetary formats, including the currency symbol for the locale, thousands separator, sign position, the number of fractional digits, and so forth.
    LC_NUMERIC
    Specifies the decimal delimiter (or radix character), the thousands separator, and the grouping.
    LC_COLLATE
    Specifies a collation order and regular expression definition for the locale.
    LC_MESSAGES
    Specifies the language in which the localized messages are written, and affirmative and negative responses of the locale (yes and no strings and expressions).
    You can use command
    # locale -k LC_CTYPE
    to see more detail about each type.

  • Help required in HR/OM Module

    hi
    Iam very new to abap hr and om module in hr.
    I have a query.My requirement is that i need to get the manager for the employees in the organisation.
    Also i need to get the manager last name,first name from pa0002 through nachn,vorna .There is a relationship mentioned for this field in the mapping. Relationship A012 to employee's organisation unit.Using the above information how can i get the manager information for a person in the organisation?Can anyone help me out  in this regard?

    >FUNCTION zhr_get_manager.
    >*"----
    >""Local Interface:
    >*"  IMPORTING
    >*"     VALUE(FI_PLANS) TYPE  PLANS OPTIONAL
    >*"  EXPORTING
    >*"     VALUE(FE_NACHN) TYPE  NACHN
    >*"     VALUE(FE_VORNA) TYPE  VORNA
    >*"     VALUE(FE_PERNR) TYPE  PERSNO
    >*"  EXCEPTIONS
    >*"      NO_REPORT_TO
    >*"      NO_POSITION_HOLDER
    >*"      NO_NAME_FOUND
    >*"----
    >  DATA :  lv_sobid  LIKE hrp1001-sobid,
    >          lv_pernr  LIKE hrp1001-sobid.
    >
    >
    > 1) Get report-to position.
    >  SELECT SINGLE sobid  FROM hrp1001 INTO lv_sobid WHERE
    >                              otype EQ 'S'            AND
    >                              objid EQ fi_plans       AND
    >                              plvar EQ '01'           AND
    >                              relat EQ '002'          AND
    >                              rsign EQ 'A'            AND
    >                              sclas EQ 'S'            AND
    >                              begda LE sy-datum       AND
    >                              endda GE sy-datum.
    >  IF sy-subrc NE 0.
    >    RAISE no_report_to.
    >  ENDIF.
    >
    >* 2) Get position holder (Manager ID)
    >  SELECT SINGLE sobid  FROM hrp1001 INTO lv_pernr WHERE
    >                           otype EQ 'S'            AND
    >                           objid EQ lv_sobid       AND
    >                           plvar EQ '01'           AND
    >                           relat EQ '008'          AND
    >                           rsign EQ 'A'            AND
    >                           sclas EQ 'P'            AND
    >                           begda LE sy-datum       AND
    >                           endda GE sy-datum.
    >  IF sy-subrc NE 0.
    >    RAISE no_position_holder.
    >  ENDIF.
    >
    >fe_pernr = lv_pernr.
    >
    >* 3) Get Manager First Name and Last Name.
    >  SELECT SINGLE vorna nachn FROM pa0002 INTO (fe_vorna, fe_nachn) WHERE
    >                               pernr EQ fe_pernr  AND
    >                               begda LE sy-datum  AND
    >                                endda GE sy-datum.
    >  IF sy-subrc NE 0.
    >    RAISE no_name_found.
    >  ENDIF.
    >
    >ENDFUNCTION.
    There are other standard functions which you can use as well.
    >RH_GET_MANAGER_ASSIGNMENT

  • SQL Query Help - Is this possible or impossible????

    Hi guys,
    I need help with an SQL query that I'm trying to develop. It's very easy to explain but when trying to implement it, I'm struggling to achieve the results that I want.....
    For example,
    I have 2 tables
    The first table is:
    1) COMPANY create table company (manufacturer varchar2(25),
                                                          date_established date,
                                                          location varchar2(25) );My sample test date is:
    insert into company values ('Ford', 1902, 'USA');
    insert into company values ('BMW', 1910, 'Germany');
    insert into company values ('Tata', 1922, 'India');The second table is:
    2) MODELS create table models (manufacturer varchar(25),
                                                 model varchar2(25),
                                                 price number(10),
                                                 year date,
                                                 current_production_status varchar2(1) ) ;My sample test data is:
    insert into models values ('Ford', 'Mondeo', 10000, 2010, 0);
    insert into models values ('Ford', 'Galaxy', 12000,   2008, 0);
    insert into models values ('Ford', 'Escort', 10000, 1992, 1);
    insert into models values ('BMW', '318', 17500, 2010, 0);
    insert into models values ('BMW', '535d', 32000,   2006, 0);
    insert into models values ('BMW', 'Z4', 10000, 1992, 0);
    insert into models values ('Tata', 'Safari', 4000, 1999, 0);
    insert into models values ('Tata', 'Sumo', 5500,   1996, 1);
    insert into models values ('Tata', 'Maruti', 3500, 1998, 0);And this is my query:
    SELECT
            com.manufacturer,
            com.date_established,
            com.location,
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
            mod.current_production_status
    FROM
           company com,
           models mod
    WHERE
          mod.manufacturer = com.manufacturer
          and com.manufacturer IN ('Ford', 'BMW', 'Tata')
          and mod.current_production_status IN (1,0)
    ORDER BY
            mod.current_production_status DESCWhat I want the query to output is this:
    com.manufacturer        com.date_established          com.location          mod.model          mod.price             mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    BMW               1910                    Germany               -               -               -          0
    Tata               1922                    India               Sumo               5500               1998          1If current_production_status is 1 it means this particular model has been discontinued
    If current_production_status is 0 it means the manufacturer does not have any discontinued models and all are in procuction.
    The rule is only one record per manufacturer is allowed to have a current_production_status of 1 (so only one model from the selection the manufactuer offers is allowed to be discontinued).
    So the query should output the one row where current_production_status is 1 for each manufacturer.
    If for a given manufacturer there are no discontinued models and all have a current_production_status of 0 then ouput a SINGLE row that only includes the data from the COMPANY table (as above). The rest of the columns from the MODELS table should be populated with a '-' (hyphen).
    My query as it is above will output all the records where current status is 1 or 0 like this
    com.manufacturer        com.date_established          com.location          mod.model          mod.price          mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    Tata               1922                    India               Sumo               5500               1998          1
    Ford               1902                    USA               -               -               -          0                    
    Ford               1902                    USA               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    Tata               1922                    India               -               -               -          0
    Tata               1922                    India               -               -               -          0However this is not what I want.
    Any ideas how I can achieve the result I need?
    Thanks!
    P.S. Database version is '10.2.0.1.0'

    Hi Vishnu,
    Karthiks query helped...
    But this is the problem I am facing...
    SELECT
            com.manufacturer,
            com.date_established,
            com.location,
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
            mod.current_production_status
    FROM
           company com,
           models mod
    WHERE
          mod.manufacturer = com.manufacturer
          and com.manufacturer = 'Ford'
          and mod.current_production_status IN (1,0)
    ORDER BY
            mod.current_production_status DESCThe value of:
    and com.manufacturer = 'Ford'will be dependent on front end user input....
    When I run the query above I get all the rows where current_production_status is either 1 or 0.
    I only require the rows where current_production_status is 1.
    So if I amend it to look like this:
         and mod.current_production_status = 1This works....
    BUT if a user now passes in more than one manufacturer EG:
    and com.manufacturer IN ('Ford', 'BMW')The query will only return the one row for Ford where current_production_status is 1. However because BMW has no models where current_production_status is 1 (all 3 are 0), I still want this to be output - as one row....
    So like this:
    com.manufacturer        com.date_established          com.location          mod.model          mod.price             mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    BMW               1910                    Germany               -               -               -          0So (hopefully you understand), I want both cases to be catered for.....whether a user enters one manufacturer or more than one...
    Thanks you so much!
    This is really driving me insane :-(

  • Bucket query help

    create table rangespendbucket(rangespend varchar2(40), id number)
    insert into rangespendbucket values('100-200',1);
    insert into rangespendbucket values('200-500',2);
    insert into rangespendbucket values('500-1000',3);
    insert into rangespendbucket values('1000-',4);
    commit;
    create table spend(supplier varchar2(40), cy_spend number)
    insert into spend values('A',100);
    insert into spend values('B',25);
    insert into spend values('C',30);
    insert into spend values('D',1000);
    insert into spend values('E',10);
    insert into spend values('A',200);
    insert into spend values('F',0);
    insert into spend values('E',20);
    insert into spend values('C',540);
    insert into spend values('B',300);
    insert into spend values('A',300);
    insert into spend values('C',10);
    insert into spend values('B',0);
    insert into spend values('E',0);
    insert into spend values('G',90);
    insert into spend values('H',0);
    insert into spend values('A',0);
    insert into spend values('P',7000);
    commit;
    i am new in this forums . some one in my company given me the following query/task.
    I want find out all those in a single query(1-8) except 1.1(separatee query).
    we are using oracke 10g reaalese 2 version.
    1)no of customer/supplier in the spend bucket.
    1.1. If anybody clcik on that particular bucket it will show no of suppliers.
    2)total no of supplier for all bucket(sum)
    3)% of supplier for each bucket.(each bucket supp cnt *100/total supp cnt)
    3)total spend for each bucket
    4)total spend for all combination of bucket
    5)% of spend for each bucket than total bucket(each bucket supp spend *100/total supp spend)
    6)how many no of suppliers make 80% of total spend(respect to all bucket)
    7)how many no of suppliers make 20% of total spend(respect to all bucket)
    8)top 3 suppliers make how much % of spend(respect to all bucket)
    i am eagerly requesting to all of you please help me to making this query.
    this query is required for making dashboard.
    column name should be like this-totalsupplierscnt__all_bucket,'cnt suppliers 100-200','%cnt suppliers 100-200','cnt supplier 200-500','%cnt supplier 200-500',
    'cnt supplier 500-1000','%cnt supplier 500-1000','cnt suppliers 1000-','%cnt suppliers 1000-',
    totalsuppliersspend_all_bucket,'spend for 100-200','%spend for 100-200','spend for 200-500','%spend for 200-500',
    'spend for 500-1000','%spend for 500-1000','spend for 1000-','%spend for 1000-',
    'no of supplierss 80% of total spend'(calculation-suppose total spend 100. spend sorted by decending 80% of total spend may cover 1-2 suppliers),
    'no of supplierss 20% of total spend'(calculation- total no of suppliers- no of suppliers making 80% spend),
    'top 3 suppliers spend'(calculation-spend sorted by desc,if we get total spend then we calculate -top3'spend*100/total spend)
    if you want much more clarification i will give you.
    Edited by: 949497 on Jul 27, 2012 7:51 PM
    Edited by: 949497 on Jul 27, 2012 8:11 PM

    Hi,
    Welcoem to the forum!
    949497 wrote:
    create table rangebucket(rangespend varchar2(40), id number) ...Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful!
    i am new in this forums ....You're way ahead of some people, who have been using the forum for years but still haven't learned how to post their data.
    Don't forget to post the exact results you want from that data.
    How are the two tables related? Do you have to parse rangebucket.rangespend to extract the NUMBERs 100 and 200 from the VARCHAR2 '100-200'? It would be simpler to do it the other way around: store the NUMBERs 100 and 200 in two separate NUMBER columns, and derive the label '100-200' from them (or store the label in a separate column, as it is now, in addition to rangebegin and rangeened NUMBER columns).
    Whatever number is related to these ranges, what happens if that number is exactly 200? What if it is less than 100?
    >
    I want find out all those in a single query(1-8) except 1.1(separatee query).
    we are using oracke 10g reaalese 2 version.Thanks! That's another thing that's always imoportant (and another thing some people haven't learned to do).
    1)no of customer/supplier in the spend bucket.
    1.1. If anybody clcik on that particular bucket it will show no of suppliers.This is the SQL and PL/SQL forum. What do you mean by "click", and how does it involve SQL or PL/SQL?
    2)total no of supplier for all bucket(sum)
    3)% of supplier for each bucket.(each bucket supp cnt *100/total supp cnt)
    3)total spend for each bucket
    4)total spend for all combination of bucket
    5)% of spend for each bucket than total bucket(each bucket supp spend *100/total supp spend)
    6)how many no of suppliers make 80% of total spend(respect to all bucket)I'm not certain I understand what any of the outputs are, but I'm especially unsure of 6) and 7).
    Do you want the smallest possible number of suppliers, such that their spend totals account for at least 80% of all spend total?
    Do you want the largest possible number of suppliers, such that their sepnd total just barely exceeds 80% of the overall total?
    Do you want something else entirely?
    When you post the results you want from the given sample data, explain this part very carefully.
    7)how many no of suppliers make 20% of total spend(respect to all bucket)
    8)top 3 suppliers make how much % of spend(respect to all bucket)I suspect you'll need to use aggregate functions to get the total by suppliers, and then use analytic fucntions to answer questions such as "Is the running total greater than 80% yet?". I'm sure this will be clearer after you post the results you want.

  • XSLT mapping Help Required.

    XSLT mapping Help Required.
    Hi Experts,
    I am New to XSLT Mapping. I am practising the below Example:
    InputXML File:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
    <ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
    <Person>
    <FirstName>Anshul</FirstName>
    <LastName>Chowdhary</LastName>
    <Gender>Male</Gender>
    <Address>
    <Street>2nd Main</Street>
    <Houseno>83/b</Houseno>
    <City>Mysore</City>
    </Address> </Person>
    </ns0:MT_XSLT_Source>
    XSL StyleSheet File:
    <?xml version='1.0' encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/Gen"
    Xmlns:ns1=”http://XYZ.com/Test”>
    <xsl:template match="/">
    <ns1:MT_XSLT_Target>
    <Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title>
    <Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/>
    </Name>
    <Street> <xsl:value-of select="concat(concat(ns0:Mt_XSLT_Source/Person/Address/Houseno,' '),
    ns0:Mt_XSLT_Source/Person/Address/Street)"/> </Street>
    <City> <xsl:value-of select="ns0:Mt_XSLT_Source/Person/Address/City"/> </City>
    </ns1:MT_XSLT_Target>
    </xsl:template>
    </xsl:stylesheet>
    The Desired Output shuold be:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:MT_XSLT_Target xmlns:ns1="http://XYZ.com/Test">
    <Title>Male</Title>
    <Name>Anshul Chowdhary</Name>
    <Street>83/b 2nd Main</Street>
    <City>Mysore</City>
    </ns1:MT_XSLT_Target>
    I have refered the xsl in xml and i am getting the below Oupt in a Single line like this:
    Anshul Chowdhary Male 2nd Main 83/b Mysore
    I am Unable to display in Target XML Fomrat as shown above. Please check and do the needful.
    Regards,
    GIRIDHAR

    Hi,
    I have used below for testing.
    Input xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
    <ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
    <Person>
    <FirstName>Anshul</FirstName>
    <LastName>Chowdhary</LastName>
    <Gender>Male</Gender>
    <Address>
    <Street>2nd Main</Street>
    <Houseno>83/b</Houseno>
    <City>Mysore</City>
    </Address> </Person>
    </ns0:MT_XSLT_Source>
    xsl code:
    <?xml version='1.0' encoding="UTF-8"?> 
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/gen" 
        xmlns:ns1="http://XYZ.com/Test"> 
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
        <xsl:template match="/"> 
            <ns1:MT_XSLT_Target> 
                <Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title> 
                <Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/> 
                </Name> 
                <Street> <xsl:value-of select="concat(concat(/ns0:MT_XSLT_Source/Person/Address/Houseno,' '), 
                    /ns0:MT_XSLT_Source/Person/Address/Street)"/> </Street> 
                <City> <xsl:value-of select="/ns0:MT_XSLT_Source/Person/Address/City"/> </City> 
            </ns1:MT_XSLT_Target> 
        </xsl:template> 
    </xsl:stylesheet>
    For testing in PI ,change the extension from .txt to .xsl and zip it and upload into PI as an imported archive .
    Regards
    Venkat

  • Query Help-2

    Query Help:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=471180&tstart=15&trange=15
    It seems I have confused enough people with my improper presentation of query. Sorry guys. I will restate my question with different table names.
    The above was my previous posting, which was not clear..so Iam restating my problem as follows....
    I have the following tables
    Customer(custID, Name, Address)
    Order(custID, OrderID, orderDate)
    CreditCard(custID, creditCard#, creditCardType)
    Now if I have 3 records in Order with custID 100 and 2 records in CreditCard as
    Order:
    100,A001,11/22/03
    100,A002,11/24/03
    100,A003,12/02/03
    CreditCard:
    100,42323232..., VISA
    100,5234234...., MASTER
    Now how can I get
    custID, Name, Address, OrderID, orderDate, creditCard#, creditCarType
    data in minimum no. of records....
    I think I have made my query clear..
    now please help me guys...
    thanks so much for your help.

    You are right.
    But frankly the actual tables on my database are not customer,orders and creditcards..but I just tried to reproduce the problem with these tables, please ignore that user needs a refund etc situtaion. If the tables were actually order,creditcards etc..it would have been a problem to be considered.
    Can you please help me with the query
    if I have m rows in Order and n rows in CreditCard. I will get m*n records, I looking for max(m,n).
    With the following fields in my query result,
    custID, Name, Address, OrderID, orderDate, creditCard#, creditCarType
    from Customer, Order, CreditCard tables
    Thanks so much for your htlp

  • Help required - Sales order item is partially delivered but the item grayed

    I have a sales order 123 having say item10 with qty 1, item20 with qty 10 , item 30 qty 12
    Item 1 confirmed qty 1 and delivered qty is 1
    Item 2 confirmed qty 10 and delivered qty 10
    Item 3 confirmed qty 1 and delivered qty is 1
    Now the item3 still has open requirements of 11 to be delivered. But the item is GRAYED OUT already.
    even if I do ATP the qty is not confirming for the remaining 11 pieces.
    Why is that? How to make that item out from GRAY.
    How to confirm the remaining 11 qty for that item.
    Help required as early as possible.
    Appreciate ur help guys
    Radha

    hi Radha, how are you ?
         ---the partial deliveries in master data must have not been mentioned.
         ---the deliveries should be upto target quantity.
         ---check order type, item category and schedule line category.
         ---check unrestricted stock availability.
    thank you
    regards
    Khera.

  • Search Help with in a serach help required in SRM 4.0

    Hi,                                                     
    Requirement: Search help required for Product Category field in the Search help for Product(BBPH_PRODUCT) in SRM portal.
    This search help is used in Create shopping Cart transaction. The hyper link on Internal Goods/Services leads to the search help BBPH_PRODUCT. 
    My analysis:           
    The field Product Category (CATEGORY_ID) has search help(COM_CAT_HIER) attached to its data element. When I single test the search help BBPH_PRODUCT in SAP GUI,I can see the search help for field product category in the selection dialogue box. However the same does not appear on the corresponding screen in HTML.
    Please let me know whether I need to do some thing to make the search help appear on the HTML screen?
    With Regards,         
    Prakash Kamath

    Hi Prakash,
    I have the same problem but with another field. Unloading point. Could you please tell me how did you solve this problem with displaying F4 help on html/ SRM portal?
    Thank you very much.
    Best regards,
    Danijela ZIvanovic

  • Help required with Photoshop Elements 4.0 this has been installed on my new Toshiba laptop with windows 8.1 for some 18 months and operating well. Now it will not open, message pops up saying "attempt to access invalid address" then "application not respo

    Help required with Photoshop Elements 4.0 this has been installed on my new Toshiba laptop with windows 8.1 for some 18 months and operating well. Now it will not open, message pops up saying “attempt to access invalid address” then “application not responding” Suggestions how to access would be much appreciated. Tks. Stuart

    What is the size of your hard disk?  PSE 4 is a very old program and I suspect it is not able to access the entire hard disk on your machine.  Just a thought here.

  • Help require with installing Adobe Acrobat onto my Macbook Pro Retina.

    Help require with installing Adobe Acrobat onto my Macbook Pro Retina.
    I have successfully installed all of my creative cloud apps with the exception being acrobat.
    I cannot print from Indesign to PDF.
    I have unistalled, reinstalled and still no Adobe Acrobat.
    I now have to go back to Windows 8 and create the PDF's there.
    Any one know how to get around this issue?
    Thanks in advance
    Kelvin

    OSX has effectively killed the ability to print to pdf, (print to pdf eliminates most of the "Rich features" of current pdf).
    Export from InDesign, always, excpet for the 1% of the time where you know why print to pdf would produce a better result.

  • Help required in Weblogic 6 - Creation & Configuration of Web Application

    Forum Home > Enterprise JavaBeans[tm]
    Topic: Help required in Weblogic 6 - Creation & Configuration of Web Application
    Duke Dollars
    2 Duke Dollars assigned to this topic. Reward the best responses to your question
    using the icons below, or transfer additional Duke Dollars to this topic.
    Welcome moinshariff!
    Watching this topic.
    Previous Topic Next Topic
    This topic has 1 reply on 1 page (Most recent message: Jan 23, 2002 1:05 AM)
    Author: moinshariff Jan 22, 2002 4:55 AM
    Hi,
    I am using Weblogic 6. I have created a new Web
    Application called Web (I have not used the DefaultWebApp_myserver).
    And I have the following settings:
    Name : Web
    URI : Web
    and Path : C:\Web
    and placed my JSP files under c:\Web\
    I am able to access the first page, but after that I am not able to access the
    second page.
    I get "Error 404--Not Found" on the browser. Basically the class file is not getting
    created under /Web-inf/_tmp_war_myserver_myserver_Web/jsp_servlet/ folder .
    I tried a work around for this. I copied all my files under one more folder called
    web and placed this under C:\Web
    The it works. Now I have 2 copied off all the files, 1 copy under c:\web and another
    copy under c:\web\web\.
    If I have the files under DefaultWebApp_myserver and have the setting as
    Name: DefaultWebApp_myserver
    URI: DefaultWebApp_myserver
    Path: .\config\mydomain\applications
    everything works fine.
    Can any one please let me know if there is any configuration which has to be done
    so that I do not duplicate the code in 2 directories
    Thanks in advance.
    Regards,
    Moin

    Forum Home > Enterprise JavaBeans[tm]
    Topic: Help required in Weblogic 6 - Creation & Configuration of Web Application
    Duke Dollars
    2 Duke Dollars assigned to this topic. Reward the best responses to your question
    using the icons below, or transfer additional Duke Dollars to this topic.
    Welcome moinshariff!
    Watching this topic.
    Previous Topic Next Topic
    This topic has 1 reply on 1 page (Most recent message: Jan 23, 2002 1:05 AM)
    Author: moinshariff Jan 22, 2002 4:55 AM
    Hi,
    I am using Weblogic 6. I have created a new Web
    Application called Web (I have not used the DefaultWebApp_myserver).
    And I have the following settings:
    Name : Web
    URI : Web
    and Path : C:\Web
    and placed my JSP files under c:\Web\
    I am able to access the first page, but after that I am not able to access the
    second page.
    I get "Error 404--Not Found" on the browser. Basically the class file is not getting
    created under /Web-inf/_tmp_war_myserver_myserver_Web/jsp_servlet/ folder .
    I tried a work around for this. I copied all my files under one more folder called
    web and placed this under C:\Web
    The it works. Now I have 2 copied off all the files, 1 copy under c:\web and another
    copy under c:\web\web\.
    If I have the files under DefaultWebApp_myserver and have the setting as
    Name: DefaultWebApp_myserver
    URI: DefaultWebApp_myserver
    Path: .\config\mydomain\applications
    everything works fine.
    Can any one please let me know if there is any configuration which has to be done
    so that I do not duplicate the code in 2 directories
    Thanks in advance.
    Regards,
    Moin

Maybe you are looking for

  • The error while shutdown the server

    I installed the JDK1.3.0 and OC4J standalone Version 9.0.3.0.0. I have no problem to start the server by using oc4j.jar. However, I am not able to shutdown the server by java -jar admin.jar ormi://localhost/ admin kzhou -shutdown. J2ee_home was set t

  • How to find the position of view in MM02 transaction for coding BDC?

    Hi Guys, Is there any FM or BAPI Available to find the position of the view in MM02 transaction. I tried FM SELECTION_VIEWS_FIND. But getting inconsistent results i.e Some materials it is giving correct positions but for others i am getting wrong pos

  • Edit a file

    Once you export a pdf to word, how do you edit the file

  • Applications no long minimize when double clicking top bar in snow leopard

    Applications no long minimize when double clicking top bar in snow leopard. Got to be a snow leopard thingy because I just switched. whats the new deal now. Snow leopard has already screwedup just about all my 3rd party apps. they just cant keep up.

  • Mp3s playback broken in newest flash player

    Hi I've been developing flash sites for many years. Many of them are dynamic. Recently since upgrading the Flash Player (9,0,115,0 installed) in my Firefox browser, a flash site I've built for my university work has broken. But the same site works fi