Generation of a unique number on the columns.

Hello

Please check this query,

< pre >

SELECT DISTINCT A.LKP_ID AS ID
D.PART_CNDTN_CD as a CONDITION
D.PART_DISPOSTN_CD AS PROVISION
C.LKP_NM AS DESCRIPTION
OF FWOWNER. CLM_LKP_VALUE HAS
FWOWNER. CLM_LKP_USAGE B
FWOWNER. C CLM_LKP_VALUE_LANG
IWOWNER. WC_CLM_SRVC_PART D
WHERE B.LKP_USED_AS IN ('RR_CAUSAL_PART_CNDTN_CODE', 'rr_parts_disposition')
AND A.LKP_REF BETWEEN B.LKP_REF AND B.LKP_REF + '.' 99999
and A.LKP_ID = C.LKP_ID
AND C.LANG_CD = 'ENG_USA. '
AND A.LKP_LVL = 3
and A.LKP_VALUE = BOX
WHEN B.LKP_USED_AS IN ('RR_CAUSAL_PART_CNDTN_CODE')
THEN D.PART_CNDTN_CD
WHEN B.LKP_USED_AS IN ('rr_parts_disposition')
THEN D.PART_DISPOSTN_CD
END

< / pre >


top query let me out like,

< pre >
AVAILABLE FOR THE ID CODE DESCRIPTION
----- ------- ---------- ---------------------------------
CP07 25774 REVAMPED bad calibration
25789 CP22 leak (null)
25795 CP28 scars / covered
25796 CP29 (null) Warped/distorted/curly
25768 CP01 PROCESSED Bent/pleated/Fold/bent/blister
CP10 25777 chipped
Contamination CP12 25779
25786 CP19 grooved/crosses (null)
25793 pitted CP26 (null)
25768 CP01 (null) Bent/Creased/Fold/twisted/Crinkled
25777 chipped CP10 (null)
CP11 25778 Circuit (null) Bad
25783 dented CP16 (null)
25790 obsolete CP23 / supplant (null)
25797 CP30 (null) worn too
25798 CP31 (null) bad part
* 25799 CP32 (null) other *.
* Other CP32 25799 *.
28225 CP07 REVIEW REVIEW
25771 CP04 Broken/fractured (null)
25779 CP12 Contamination (null)
25780 CP13 corroded/eroded (null)
25781 CP14 Cracked (null)
25785 CP18 Galled/frettees (null)
25788 CP21 (null) failure to point
25795 CP28 Scarred/Spalled (null)
CP30 25797 door too
28225 CP01 REVIEW REVIEW

28 response (s) selected [extract metadata: 0/ms] [extract data: 0/ms]


< / pre >

Please see the part "BOLD", I get two duplicates with a vertical drop of NULL and empty space I want to generate a unique number on the CONDITION column and available how to do this.


(Please check my previous thread of reference
MERGE TWO COLUMNS?
)

This is not Oracle...

In any case:

SELECT  DISTINCT A.LKP_ID          AS ID
,       D.PART_CNDTN_CD          as CONDITION
,       CASE WHEN LENGTH(D.PART_DISPOSTN_CD)=0 or D.PART_DISPOSTN_CD IS NULL THEN null ELSE D.PART_DISPOSTN_CD END  AS DISPOSITION
,       C.LKP_NM AS DESCRIPTION
FROM     FWOWNER.CLM_LKP_VALUE          A
,     FWOWNER.CLM_LKP_USAGE          B
,     FWOWNER.CLM_LKP_VALUE_LANG      C
,     IWOWNER.WC_CLM_SRVC_PART     D
WHERE     B.LKP_USED_AS          IN ( 'RR_CAUSAL_PART_CNDTN_CODE', 'rr_parts_disposition')
AND     A.LKP_REF          BETWEEN     B.LKP_REF     AND     B.LKP_REF + '.99999'     -- No quotes
and     A.LKP_ID          = C.LKP_ID
AND     C.LANG_CD          = 'ENG_USA'
AND     A.LKP_LVL          = 3
and      A.LKP_VALUE          = CASE
                         WHEN  B.LKP_USED_AS     IN ( 'RR_CAUSAL_PART_CNDTN_CODE')
                         THEN  D.PART_CNDTN_CD
                         WHEN  B.LKP_USED_AS     IN ('rr_parts_disposition')
                         THEN  D.PART_DISPOSTN_CD
                      END

Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

Tags: Database

Similar Questions

  • The number of the column datatype story

    The number of the column datatype story

    Hello

    We have the existing DB table with created_by and updated_by NUMBER data type columns. I created EO/VO using the same table.

    As and when we click on + symbol for (insert a newline) browser of Oracle business components... Get the following error message

    Exception in thread "AWT-EventQueue-0" oracle.jbo.domain.DataCreationException: Houston-25009: failed to create an object of type: java.lang.Long type: java.lang.String with value: covering

    As the old huge with content DB table. I'm sure, that I can not change the data type of these two columns in DB.

    I have a possibility to exclude these two columns when creating entity object.

    It would be great, if you can suggest other options to avoid this problem by including these two columns.

    JDev - 11.1.1.5.0

    Thank you

    LSs

    Now, I could solve the problem as you have suggested.

    Thank you

    MSR.

  • Matrix of distances: selection of values with the number of the column as a variable

    Hi all

    You wonder if SQL can do natively, let's go.

    I have a static table with the same amount of rows and columns, that changes forever; It represents the distances between locations (e.g. countries).
    It's basically a distance matrix (you can find a good example on Wikipedia ).

    My SQL statement must extract the distances of this matrix, based on the IDS of countries located in another table.
    Select a field is simple:

    SELECT * from cdistances where countryid =
    (select countryid from countries where upper (country) = upper (& getcountry));

    When I run the present, I get a line of all distances to all countries of the country I go when asked. But I would limit the outcome of a country of destination that I entered.

    Of course, a CASE statement would solve this nicely, but since we are talking more than 200 countries, which will become unmanageable.

    Another method that I approached is to use a variable as a column, as below:

    SELECT & getdestination of cdistances where countryid =
    (select countryid from countries where upper (country) = upper (& getcountry));

    It works well when I get directly the column identifier (manually from the keyboard) but I would like to automate even further.
    My names of columns in the matrix of distances are named as follows:
    countries1, countries2, countries3... country200 - where the number ID the real country, preceded by the constant string 'country '.
    So I tried to define a variable as a concat between 'country' and another variable:
    def getd2 = concat ("D2C", & testcountryid);
    Of course, it does not; the output of the script is:

    old: def getd2 = concat ('country', & testcountryid)
    New: def getd2 = concat ("country", 12)

    where I expected to be 'country12.

    I'm so little loss of thoughts. Maybe I'm pushing my train of thought in the wrong way, so I guess the general question would be: how to select a specific column of a table based on information outside the SQL statement dynamically?

    Hello

    I'm still confused.
    Is your table called chessking or testdistances, or you have 2 separate tables?

    I'm guessing that your single table is testdistances, and you want to pass a list of countryids, such as that of 3.1 to a query and get results as follows:

    `COUNTRYID  DISTANCE3  DISTANCE1
    ---------- ---------- ----------
             1         18         15
             3         13          1
    

    If so:

    DEFINE     country_list = "3,1"
    
    -- Preliminary Query, to set column_list
    COLUMN     column_list_col     NEW_VALUE column_list
    
    SELECT     'distance' || REPLACE ( '&country_list'
                               , ','
                         , ',distance'
                         )          AS column_list_col
    FROM    dual;
    
    -- Main Query
    SELECT     countryid
    ,     &column_list
    FROM     testdistances
    WHERE     countryid     IN (&country_list)
    ;
    

    Sorry, I'm out of time now. I'll explain more in a few hours.

  • With the help of inplace column number of the column name in the SQL Select statement

    Is it possible to execute instructions select sql with the number of columns in
    place names of columns?

    Run SQL
    select AddressId,Name,City from Address
    Is it possible
    select 1,2,5 from Address
    Thanks in advance

    You can extract the names of the columns for user_tab_columns
    with

    SELECT Column_name
    FROM user_tab_columns
    where table_name = 'MY_TABLE'
    and Column_id in (1,2,5)
    

    Use dynamic SQL and then the result to get the values.

    But as others already mentioned, this wil it be given incorrect if your table is changed.

  • How to split the PHONE NUMBER in the column of database?

    Hello - how to split the telephone within the same column number?

    Existing column PHONE data

    3711943

    8744723

    8487928

    3349262

    I want to split the data in the same

    371-1943

    874-4723

    etc...


    Is this possible? I need to do this only through SQL query not PL/SQL.



    SUBSTR (your_col, 1, 3). » -'|| SUBSTR(your_col,4)

  • How to increment a number between two unique number fields for columns?

    Heya

    I got this table structure

    name | ID

    one | 1
    b | 2
    d | 3

    the number column cannot contain duplicate values, so when I want to insert a field 'c' with the id of "3" via a form

    I use this method:

    -------------------


    < cfif IsDefined "(FORM. MM_InsertRecord") AND the FORM. MM_InsertRecord EQ 'form1' >

    < cfquery datasource = 'my_db' >

    UPDATE CATEGORIES
    SET category_order_mnu = category_order_mnu + 1
    WHERE category_order_mnu > #FORM.category_order_mnu #;

    INSERT INTO CATEGORIES (category_name, category_order_mnu)
    VALUES)
    < cfif IsDefined ("FORM.category_name") AND #FORM.category_name # NEQ "" > "".
    "#FORM.category_name #".
    < cfelse >
    NULL VALUE
    < / cfif >
    ,
    < cfif IsDefined ("FORM.category_order_mnu") AND #FORM.category_order_mnu # NEQ "" > "".
    #FORM.category_order_mnu #+1
    < cfelse >
    NULL VALUE
    < / cfif >
    )
    < / cfquery >
    < / cfif >

    ------------


    The problem is that I get this error message:
    Quote:

    "" Characters found after end of SQL Plus? »

    The error occurred in C:\CFusionMX7\wwwroot\aiav1\aiacp\categories\addcategory.cfm: line 40

    38: < cfelse >
    39: NULL
    40: < / cfif >
    41 :)
    42: < / cfquery >

    CATEGORIES of UPDATE SQL SET category_order_mnu is category_order_mnu + 1 WHERE category_order_mnu > 3;. INSERT INTO CATEGORIES (category_name, category_parent_id, category_visible, category_tooltip, category_order_mnu) VALUES ('Programme', 0, NULL, 3 + 1)
    DATASOURCE my_db
    VENDORERRORCODE 3092
  • Unique number with the manipulation of XML on the 8520 with OS 4.6

    Our application works on many devices with os 4.6 to 7. It's a platform for learning with a function like get server classes and show to the user. This course has the configuration xml file this demand analysis.

    App works fine on all phones, except one, it is 8520 with OS 4.6. In the log file, I see that the issue is part of the analysis of this xml file. Is classic DOM parser but this code works well on all OTHER phones, so the question is not in the format of this file. In addition, we cannot reproduce the developer side with Simulator, this problem only exists on the real phone.

    I guess that this problem is specific for 8520 with OS 4.6 and probably that you encountered with this at the beginning. So if you have the answer or guess it please share it with me. Any help would be apreciated.

    I mislead you.

    His language classic gap between me and my client. We didn't understand, and now this error occurs on many devices. So my question is meaningless.

    Thank you for your help.

  • How to add the number of the column by another county sql statement

    My problem is

    SELECT Count (DISTINCT num) OF tmp_table;

    the foregoing will return 13.


    UPDATE seq_table a SET a.currentvalue = a.currentvalue + 1 + (SELECT Count(DISTINCT num) FROM tmp_table;)  WHERE a.seq_type LIKE 'ABC% ';

    the result of updating should be = a.currentvalue + 1 + 13

    How is that possible? There is syntax error...

    Not sure if this was clear ;-), but there's a semicolon behind tmp_table and SQL does not understand that.

    Then

    UPDATE seq_table SET a.currentvalue = a.currentvalue + 1 + (SELECT Count(DISTINCT num) FROM tmp_table) WHERE a.seq_type LIKE 'ABC% ';

  • Number of the column of a cell

    Hello

    I have a cell object and I want to know which column it's in. How do I do that with JavaScript? Thank you very much.

    Rick

    myCell.parentColumn.index;

    Peter

  • Now that the definition of the columns for this result?

    I have a table with two columns. A column is a column HolidayCode and varies from H1 - H20, the next column is the column DateDeparted.

    The rules, which I want to apply are that you can't have the same HolCode with the same DateDeparted, for example H1 - October 12, 2001, H1-12-Oct-2001.

    However the same HolCode can be used with a different date, and the same date can be used with different HolCode.

    How it is after a single entry and cannot be entered again?

    Thanks for your help!

    Create [url http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/clauses002.htm#SQLRF01111] composite unique key on the columns.

  • Number of unique values in 7 columns

    Hey there...
    I have a table of correspondence with 8 columns
    ID = unique ID
    U = Sunday,
    M = Monday
    T = TUE
    W = married
    R = Thur
    F = Fri
    S = Sat

    Each of the columns 'day' can be a value between 1 and 1150, looks like this

    ID U M T W R F S
    1 15 15 16 15 17 345 17

    What I'm trying to find is a county of the deviation of each line... or how many days have different values

    So for the example above

    ID U M T W R F S COUNTY
    1 15 15 16 15 17 345 17 4

    There are have 4 unique values in the week...
    15,16,17,345

    Any ideas on how this could be done in oracle? Puzzled!
    SQL> create or replace
      2    type NumberList
      3      as
      4         table of number
      5  /
    
    Type created.
    
    SQL> with sample_table as(
      2                       select 1 ID,15 U,15 M,16 T,15 W,17 R,345 F,17 S from dual
      3                      )
      4  select  s.*,
      5          cardinality(set(NumberList(U,M,T,W,R,F,S))) cnt
      6    from  sample_table s
      7  /
    
            ID          U          M          T          W          R          F          S        CNT
    ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
             1         15         15         16         15         17        345         17          4
    
    SQL> 
    

    SY.

  • A formula allows the last number in a column?

    Is it possible to have a work formula with the last number in a column or line automatically?

    For example:

    Col Col B

    Jan                    20

    21 Feb

    Mar                    18

    Apr                    16

    May

    Jun

    Jul

    I would like to be able to have a use form the last number in column B. I'll add the numbers to the list each month. And the sort numbers is not realistic because of the aspect from month to month.

    I know that I can change the formula of each month, but automatic is less prone to errors. It doesn't seem to be a function of 'last '. I work in the latest version of numbers and prefer not to spend at Excel.

    Any suggestions?  Thank you.

    .. Doug

    If you have no empty cells in the column, you can do something like this:

    = INDEX (array 1::B, COUNTA (table 1::B) + 1).

    The + 1 is necessary if there is a header row.

    SG

  • valor en el number provided excel buscar una Tabla of la fila y el of the column

    Hola; Quisiera hacer para buscar una tabla con el valor as Trin excel in VI el number of la fila y el of the column that is. For example, tabla FR the siguiente, introduciendo Fila 2 Columna of y 3 should provide the value 12. Gracias.

    Column 1

    Column 2

    Column 3

    Fila 1

    10

    21

    45

    Fila 2

    8.5

    5

    12

    Fila 3

    1.2

    20.3

    4.6

    Perfecto. A millon of gracias.

  • ORA-02256: number of referencing columns must match the referenced column

    The following script produces

    ORA-02256: number of referencing columns must match the referenced columns, can't think of any reason, someone has an idea?

    Please help, I am stuck on an assignment...!

    Capture.PNG

    drop table qualitycheck;

    drop table distribution;

    Manager to move table;

    CREATE THE TABLE MANAGER)

    MgrID number (4),

    mfirstname varchar2 (30),

    msurname varchar2 (30),

    Primary key (mgrid)

    );

    CREATE DISTRIBUTION TABLE)

    ProdID number (4) CONSTRAINT NN_PRODUCT_prodid NOT NULL,

    MgrID number (4) CONSTRAINT NN_MANAGER_mgrid NOT NULL,

    Primary key (prodid, mgrid)

    CONSTRAINT FK_ALLOCATION_MANAGER_mgrid Foreign Key (mgrid) REFERENCE MANAGER,

    CONSTRAINT FK_ALLOCATION_PRODUCT_prodid Foreign Key (prodid) REFERENCES PRODUCED

    );

    CREATE TABLE QUALITYCHECK)

    ProdID number (4) CONSTRAINT NN_ALLOCATION_prodid NOT NULL,

    MgrID number (4) CONSTRAINT NN_ALLOCATION_mgrid NOT NULL,

    number of weekno (2),

    Partition number (1),

    Primary key (prodid, mgrid, weekno)

    CONSTRAINT FK_QUALITYCHECK_PRODUCT_prodid Foreign Key (prodid) ATTRIBUTION of REFERENCES,

    CONSTRAINT FK_QUALITYCHECK_MANAGER_mgrid Foreign Key (mgrid) ASSIGNMENT of REFERENCES

    );

    Hello

    Reason is the primary key of the table that is assigned prodid, mgrid, but you try to create the foreign key columns separately.

    Try which follows and this should work:

    CREATE TABLE QUALITYCHECK (
      prodid number (4) CONSTRAINT NN_ALLOCATION_prodid NOT NULL,
      mgrid number (4) CONSTRAINT NN_ALLOCATION_mgrid NOT NULL,
      weekno number (2),
      score number (1),
    
    Primary Key (prodid,mgrid,weekno),
    
    CONSTRAINT FK_QUALITYCHECK_PRODUCT_FK Foreign Key (prodid, mgrid) REFERENCES ALLOCATION
    );
    
  • Create customize to generate number in the automatic column

    Hi all..

    I want to create customize for this case.

    If I click the receive method, example I select bank transfer, then in the column automatic receipt number turn off and generate the number, for example: if I select the bank transfer, the receipt number will generate number 'BT15080001 '.

    I'll explain for this receipt number:

    'BT15080001 '.

    -> BT for bank transfer method. If the method Cash, code = CS, if method Giro & Check, code = GC

    -> 15 for the year (sysdate)

    -> 08 months (sysdate)

    -> sequence number of 0001

    Thus, number of receipt generates automatic and column turn off after that I selected the method of reception.

    I can do using customize.

    If I can, how?

    Thank you all...

    per.jpg

    Yes its possible.

    Relaxation-

    A TIMES-NEWS-ITEM_INSTANCE

    Object-

    Receipt number

    Action-

    SEQ 1

    Assign the value of approval number

    EG - substr (recipt_method, 1, 2). TO_CHAR (sysdate, 'YY') | TO_CHAR (sysdate, 'MM') | Seq.nexval

    SEQ 2

    Disable the receipt number filed by setting disable update

    Hope this will help you...

    Kind regards

    Aryan

Maybe you are looking for

  • Swollen battery

    I have a Macbook Pro 2010 and the battery began to swell, obviously I didn't screw and I ordered one online, after a week when I got the screws and removed the battery that's how I found the battery. I wonder who could be dangerous. I do not have the

  • Conference room mode - how to activate it?

    I've configured Mode Conference room on my Apple TV... but how do I get the Apple TV will "go in" conference mode? When that I start the Apple TV for the first time, Yes, it will go into conference mode. But the touch of any button takes out, and the

  • Satellite A200-13O - my wireless switch button is broken

    I have a laptop Toshiba A200-13O. I broke the below, wireless button while it is switched OFF... my first question: is there another way I can activate the wireless?Second question: is - this repairable... I can do, or should I take on a special tech

  • VISA resource name strings

    Hello I have a control "VISA Resource Name" on my front, according to the guidelines of the attached screenshot, which should automatically fill with the names of all the VISA resources that the PC can see. Is it possible to get a picture of these na

  • We'll be looking answersI need to keep my computer for a long low load, it turns off automatically every 15 minutes and I lose my download

    My computer shuts down in 15 minutes, I'm making a long download, how do I change the time, so it won 't stop so fast.