case on a column

Hi all


I have a table:
...
VALE_1            VARCHAR2(1) DEFAULT 'S',
     VALE_2            VARCHAR2(1) DEFAULT 'S',
     VALE_3            VARCHAR2(1) DEFAULT 'S',
     VALE_4            VARCHAR2(1) DEFAULT 'S',
     VALE_5            VARCHAR2(1) DEFAULT 'S',
     VALE_6            VARCHAR2(1) DEFAULT 'S',
     VALE_7            VARCHAR2(1) DEFAULT 'S',
     VALE_8            VARCHAR2(1) DEFAULT 'S',
     VALE_9            VARCHAR2(1) DEFAULT 'S',
     VALE_10           VARCHAR2(1) DEFAULT 'S',
     VALE_11           VARCHAR2(1) DEFAULT 'S',
     VALE_12           VARCHAR2(1) DEFAULT 'S',
where the columns VALE_1 to VALE_12 represent the months

How can I create a case in one where, according to the month that I give I can check the column for this month (VALE_month) and thus get or not to get these lines?

I'll try to explain better:

"for example, for a given DATE = 10/01/2012 (10 months, that means October), I create a simple query to only check the VALE_10 column and can have the line if its value is of."

Select * from

"Check if the VALE_10 column = s"

I hope that I was clear

Thanks in advance

Hello

Vigilant Rosario wrote:
Thanks for your time.

Very true, but she, the table, or up to 12 lines, because each row (transaction) can have 12 values (VALE_XX): has / for each month

(number of rows * 12)

It's true, then create a new table, fill it with 12 times the number of lines that are in your original table, and then move the columns from the original table.
If you cannot change the original table, you can create a view, which standardizes the columns:

CREATE OR REPLACE VIEW     notmalized_x
AS
WITH   cntr               AS
(
     SELECT     LEVEL     AS month_num
     FROM     dual
     CONNECT BY     LEVEL     <= 12
)
SELECT     x.primary_key
,     c.month_num
,     CASE  c.month_num
         WHEN  1  THEN  x.vale_1
         WHEN  2  THEN  x.vale_2
         ...
         WHEN 12  THEN x.vale_12
     END          AS vale
FROM         table_x  x
CROSS JOIN     cntr      c
;

You will notice that the CASE expression in the view is very similar to the CASE expression that Solomon has suggested.
Then, you will be able to do ion of simple queries of life, like this:

SELECT     primary_key
FROM     normalized_x
WHERE     month_num     = EXTRACT (MONTH FROM SYSDATE)
AND     vale          = 'S'
;

If you don't want to create a view, you can do normalized_x a subquery.

Tags: Database

Similar Questions

  • SUM and CASES on SEPARATE column

    1 query 1:

    SELECT IN_SRC_SYSTEM, COUNT (1)

    (SELECT

    (IN THE CASE WHERE THE VALUE LIKE '% LO %' THEN 'LO'

    WHAT VALUE LIKE ' % THE % ' THEN 'THE

    WHAT VALUE LIKE '% SAP %' THEN 'SAP '.

    WHAT VALUE AS 'SPA %' THEN 'SPA' OTHER 'OTHER '.

    IN_SRC_SYSTEM END)

    OF LOGTD

    WHEN TRUNC (DATE_AGS) = TRUNC (SYSDATE)-1

    AND LOG_STATUS = 'P '.

    AND VALUE IS NOT NULL)

    IN_SRC_SYSTEM GROUP

    ORDER BY 1;

    output:

    IN_SRC_SYSTEM count (*)

    THE 62140

    LO 59611

    SAP 2685

    SPA 95

    I changed above query returns the results online wise.

    Question:-how to add a total of column below sql. (I can reach to above sql by cumulative Group)

    SELECT

    SUM (CASE WHERE THE VALUE LIKE '% LO %' THEN 1 0) OTHERWISE END "LO."

    SUM (CASE WHERE THE VALUE AS THE ' %') THEN 1 OTHER END 0 'LA',)

    SUM (CASE WHERE THE VALUE AS "SAP %') THEN 1 OTHER 0 END 'SAP',)

    SUM (CASE WHERE THE VALUE LIKE ' % SPA %') THEN 1 ANOTHER END 'SPA' 0)

    OF LOGTD

    WHEN TRUNC (DATE_AGS) = TRUNC (SYSDATE)-1

    AND LOG_STATUS = 'P '.

    AND VALUE IS NOT NULL

    output

    THE SAP LO SPA

    62140 59611 2685 95

    2.

    SELECT ERR_SRC_SYSTEM, COUNT (VALUE)

    (SELECT DISTINCT VALUE,

    (IN THE CASE WHERE THE VALUE LIKE '% LO %' THEN 'LO'

    WHAT VALUE LIKE ' % THE % ' THEN 'THE

    WHAT VALUE LIKE '% SAP %' THEN 'SAP '.

    WHAT VALUE AS 'SPA %' THEN 'SPA' OTHER 'OTHER '.

    ERR_SRC_SYSTEM END)

    OF LOGTD

    WHEN TRUNC (DATEAGS) = TRUNC (SYSDATE)-1

    AND LOG_STATUS = 'E '.

    AND VALUE IS NOT NULL)

    ERR_SRC_SYSTEM GROUP

    ORDER BY 1;

    ERR_SRC_SYSTEM, COUNT (VALUE)

    THE 174

    LO 3

    63 SPA

    Question:-how to display columns for bottom case distinct values and the State (I can reach to above sql by cumulative Group)

    Expected:

    THE SPA SAP LO

    174-3-63-0

    I tried something below, but it didn't work because it lead to a distinct value for the column name

    SELECT

    SUM (SEPARATE CASE WHEN TRANSACTION_SID LIKE '% LO %' THEN 1 0) OTHERWISE END "LO."

    SUM (DISTINCT CASES WHERE TRANSACTION_SID LIKE ' % THE %') THEN 1 OTHER END 0 'LA',)

    SUM (DISTINCT CASES WHERE TRANSACTION_SID LIKE ' % SAP %') THEN 1 OTHER 0 END 'SAP',)

    SUM (separate BOX WHEN TRANSACTION_SID LIKE '% SPA %' THEN 1 ELSE 0 END) "SPA".

    OF OD_LG_TRANSACTION_LOG

    WHEN TRUNC (CREATED_DATE) = TRUNC (SYSDATE)-1

    AND LOG_STATUS = 'E '.

    AND TRANSACTION_SID IS NOT NULL

    Kind regards

    Veera

    It's a shame that we didn't give examples of input data to go with your question. Therefore, it is difficult to answer. Saying that, here are my attempts to answer your questions:

    (1) to add columns, you do: col1 and col2 +... + colN. This applies, even if those columns are functions - for example. (Col1) FN + fn (col2) +... + fn (colN).

    (2) maybe you're after something like ' count (distinct cases where trasnaction_sid ' % THE %' as the end value)?

    For example I think you're after, based on a small sample of the dataset:

    with sample_data as (select 1 col1, 'abc' col2 from dual union all
                         select 2 col1, 'bcd' col2 from dual union all
                         select 3 col1, 'abc' col2 from dual union all
                         select 4 col1, 'efg' col2 from dual union all
                         select 5 col1, 'abc' col2 from dual union all
                         select 6 col1, 'hij' col2 from dual union all
                         select 7 col1, 'bcd' col2 from dual union all
                         select 8 col1, 'dfg' col2 from dual union all
                         select 9 col1, 'cde' col2 from dual)
    select count(distinct case when col2 like '%b%' then col2 end) b,
           count(distinct case when col2 like '%d%' then col2 end) d,
           count(distinct case when col2 like '%l%' then col2 end) l
    from   sample_data;
    
             B          D          L
    ---------- ---------- ----------
             2          3          0
    
  • Case statement using column Date calculated in responses

    Hello

    I have a calculated column is column # 4, in the responses with the following code
    "CASE WHEN 'Handmade'." Date of the project"is set to NULL THEN TIMESTAMP ' 1900-01-01 12:00" ELSE "Handmade" "." " The project 'END' date, so now I filled all Null values in the field to date with ' 1900 - 01 - 01 12:00 '.

    I have another column with the following syntax, which only gives me an error, but the 'Undefined' values for the timestamp above is not met.
    "BOX WHEN" @4 ' = ' 1900 - 01 - 01 12:00 ' THEN 'Undefined' OTHERWISE "Main Dim". " "Project name" END ".

    Please let me know how to fix this. Thank you for your time and your help.

    Hello

    Try this

    case when cast (CASE WHEN Time. "Day Date" "IS NULL THEN TIMESTAMP ' 1900-01-01 12:00 ' time else. '" (Date of the day' END as char) = TIMESTAMP ' 1900 - 01 - 01 12:00 ' then 'undefined' other end Products.Product

    Replace your respective columns

    Thank you
    Saichand.v

  • A subquery with case returning 2 columns

    Hello

    I try a query in the format below.
    SELECT x, y, z
    FROM (SELECT Case when a
    then, y1, z1
    When b
    then, y2, z2
    END as y, z)


    Can someone tell me the correct way to do it?


    Thanks in advance :)

    Use two case statements. One for each column:

     SELECT x
         , y
         , z
      FROM
     ( SELECT CASE WHEN a THEN y1 WHEN b THEN y2 END AS y
            , CASE WHEN a THEN z1 WHEN b THEN z2 END AS z
         from some_table
     )
    

    Published by: Sentinel December 12, 2008 11:23

  • In any case for a column in a control tree not Visible?

    I would like to hide some data for a column in a tree control. There are string data that my application needs to store and retrieve from a column in a tree control, but it is relatively large and the user has no need to see.

    Is there a way to make a column of the tree control or cells is not not Visible?

    Thank you.

    Hmmm, I don't know if you can hide an arbitrary column (I don't see immediately a way to obtain a reference to it), but if your data is stored in the last column of the control, you can simply resize using the property number of columns. It does not solve all of the data stored in this column (you can resize the rear door and it'll be there).

    Actually, just thought of this: you can define a column activates (identify the column you'll work with), then use the Active cell > cell size > width to set the width of the cell 0, which resizes the entire column. You should be able to get with simple manipulations of here.

    Hope that helps,

  • Stmt case answers column fx syntax error

    Hello

    I want to update the 'Project name' column that is of type VARCHAR to "Undefined" If the "Project_date" column has a value of January 1, 1900 12:00 "." I use the stmt case following answers column Fx of 'Project name' but do syntax error.

    BOX WHEN "hand-made". "" Project_date "= January 1, 1900 12:00 ' THEN 'Undefined' ELSEWHERE 'hand made '. "' Project name ' END

    Thanks for your time and your help.

    Hi Ssk,

    It should work. Please make sure once again that the underside of things in your query:

    (1) 1st January 1900 12:00 - value exists in the column
    (2) and remove all spaces between the column name and values.

    Without spaces:

    BOX WHEN "hand-made". "Project_date" = January 1, 1900 12:00 ' THEN 'Undefined' ELSEWHERE 'hand made' "." " The project name"END;

    I would like to know if that works for you or not.

    Thank you
    -Laurence.

  • median case, conditional median

    I want to get the MEDIAN of a column IF it meets the specific criteria that that are in another column.  EXCEL can do so with the following formula:

    MEDIAN = (IF ($A:$ A = "professional association", $B: $B))

    "Because the formula itself refers to a chart, you must press CTRL + SHIFT + ENTER instead of just the ENTRY when you have finished writing the formula.

    This same formula did not work in iWork Numbers.

    Nor this one

    = IF ($A:$ A = 'professional association', MEDIAN ($B:$B)))

    I know a simple solution would be to create a new column with an IF statement, but I try to avoid that, for a number of other reasons.

    When I tried to import an Excel document into Numbers, I get the error "the array formula could not be imported and was replaced by the last computed value."

    TYPE

    TOTAL RECEIPTS

    Professional Association

    $1,601,466,444

    Professional Association

    $732,697,005

    Professional Corporation

    $601,993,361

    Professional Corporation

    $586,676,226

    Professional Association

    $466,733,002

    Professional Corporation

    $462,700,048

    Professional Association

    $457,383,677

    Professional Association

    $389,161,833

    Professional Association

    $311,840,739

    Professional Association

    $276,005,771

    The numbers do not support the so-called "table of forms" entered in Excel with ctrl-shift-enter.

    You can put the table in a range of cells (in this case an additional column), with something like this:

    The formula in column C is:

    = IF(A="trade association",B,"")

    Then take the median of this new column.

    In the second table B2, I used:

    = Median (Data::C)

    SG

  • Problem of matrix report with model RTF - text columns

    I have problem with matrix necessary report...

    I did it before using the pivot function in rtf export then the stylesheet xsl fo... model

    My problem here is in this case, the desired column (value - the center column) is the text column, and the pivot is based on the aggregate (sum or count) function that I don't want in my case.

    Attached my XML, and sample to in the excel sheet...

    and to understand the business, it's for quality module in EBS... The user can take 3 samples in the same sample for the same item, I want to show the name of tests alongside its results grouped by the number of the sample.

    any help would be much appreciated...

    This can be achieved through custom PivotTable.

    I created the RTF template for your condition.

    PFA (model and output)

  • two column values in a single column

    Hi guys,.

    I have a requirement that i want to be viewing the two column values in a single as column... values year & product will be exposed in a unique column values

    Kind regards

    Sree

    Karthickumar Pillaiyarsamy yours is a database, in OBIEE is similar with some limitations...

    Sree! you have 2 ways to do this: by using the CONCAT function or the | operator, examples here are 2 concatenating year, a space and production:

    "Time". "" T05 annually name | ' ' || ' 'Products ' '. Product P1.

    CONCAT ("Time". "T05 per year of name', CONCAT (" ","Products".)" P1 product"))

    CONCAT in OBIEE accept only 2 params, so you if want to add a space between the 2 items, you must nest your function call.

    In case your year column is a number, you can convert it to a string using CAST ("your column" as VARCHAR (10)).

  • How to disable filtering on specific columns


    Hey everybody,

    In the virtual computer objects tab the filter box top right only supports columns Name and State. All the other columns are not available in the drop-down list of filter "Select columns" (see attachment)

    How can I do this in my own personal opinion?  I have some columns (i.e. in plugin.xml) that do not support filtering on.  Thanks in advance

    -Mike

    The mechanism to remove the specific column from the drop-down list filter is not exposed in the SDK but filtering won't work in all cases for a column if you implement the corresponding method of processPropertyConstraint() for this property in your data adapter (see samples/chassis-app/chassisRackVSphere-services/src/main/java/com/vmware/samples/chassisRackVSphere/ChassisRackVSphereDataAdapter.java)

  • trigger + follow level column changes

    Hi all

    I have some paintings
    CREATE TABLE emp_details
      ( emp_number NUMBER, emp_name VARCHAR2(100)
      );
    CREATE TABLE emp_address
      (
        emp_number   NUMBER,
        emp_state    VARCHAR2(100),
        emp_district VARCHAR2(100),
        emp_pin      NUMBER
      );
    CREATE TABLE emp_contact
      (
        emp_number NUMBER,
        mobile     NUMBER,
        office     NUMBER,
        email      VARCHAR2(100)
      );
    Now, I have to follow the exact changes for all tables for all columns.

    So I intend to make my picture of history as
    CREATE TABLE emp_hist
      (
        emp_number     NUMBER,
        column_changed VARCHAR2(30),
        new_value      VARCHAR2(100),
        old_value      VARCHAR2(100),
        changed_by     VARCHAR2(100),
        changed_time DATE
      ) ;
    So I intend to create the trigger on each table to fill the record in the table hisory. but I'm a little confused. In the case where multiple columns are updated simultaneously so how can I write the trigger?

    Any help or a better idea?

    Presumably, if several columns change, you will need to insert several lines in the history table. It is usually a bad way to follow the story. Eventually generate a so many lines that it becomes very difficult to manage and query and you can join the table to itself several times in order to understand what a particular line looks like at some point in time.

    If you are determined to follow the story in this way, you could do something like

    CREATE TRIGGER emp_addr_trg
      BEFORE UPDATE ON emp_address
      FOR EACH ROW
    BEGIN
      IF UPDATING( 'EMP_STATE' )
      THEN
        INSERT INTO emp_hist( emp_number, column_changed, new_value, old_value, changed_by, changed_time )
          VALUES( :new.emp_number, 'EMP_STATE', :new.emp_state, :old.emp_state, user, sysdate );
      END IF;
    
      IF UPDATING( 'EMP_DISTRICT' )
      THEN
        INSERT INTO emp_hist( emp_number, column_changed, new_value, old_value, changed_by, changed_time )
          VALUES( :new.emp_number, 'EMP_DISTRICT ', :new.emp_district, :old.emp_district, user, sysdate );
      END IF;
    
      IF UPDATING( 'EMP_PIN' )
      THEN
        INSERT INTO emp_hist( emp_number, column_changed, new_value, old_value, changed_by, changed_time )
          VALUES( :new.emp_number, 'EMP_PIN ', :new.emp_pin, :old.emp_pin, user, sysdate );
      END IF;
    END;
    

    He'll write a line for each column that is part of the update statement. You can add additional predicates to check to determine if the value is actually change (i.e. that the: new.column_name! =: old.column_name with proper management of NULL values if the column allows it).

    Justin

  • Select only records where the column values are not all equal to zero

    Hi everyone, it seems so easy, but it has left me speechless on the research in a way that is clean, easy to achieve. I know when someone replies, I'm going to kick me. So, let's assume this is what I have:
    with mytable as (
    select 'Type 1' as itemtype, 'JAN' as monthname, 0 as theval from dual union all
    select 'Type 1' as itemtype, 'FEB' as monthname, 1 as theval from dual union all
    select 'Type 1' as itemtype, 'MAR' as monthname, 5 as theval from dual union all
    select 'Type 1' as itemtype, 'APR' as monthname, 1 as theval from dual union all
    select 'Type 1' as itemtype, 'MAY' as monthname, 4 as theval from dual union all
    select 'Type 1' as itemtype, 'JUL' as monthname, 0 as theval from dual union all
    select 'Type 1' as itemtype, 'AUG' as monthname, 0 as theval from dual union all
    select 'Type 1' as itemtype, 'SEP' as monthname, 1 as theval from dual union all
    select 'Type 1' as itemtype, 'OCT' as monthname, 7 as theval from dual union all
    select 'Type 1' as itemtype, 'NOV' as monthname, 1 as theval from dual union all
    select 'Type 1' as itemtype, 'DEC' as monthname, 2 as theval from dual union all
    
    select 'Type 2' as itemtype, 'JAN' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'FEB' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'MAR' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'APR' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'MAY' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'OCT' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'NOV' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'DEC' as monthname, 0 as theval from dual
    )
    select
      itemtype,
      sum (case monthname when 'JAN' then theval else 0 end) as JAN,
      sum (case monthname when 'FEB' then theval else 0 end) as FEB,
      sum (case monthname when 'MAR' then theval else 0 end) as MAR,
      sum (case monthname when 'APR' then theval else 0 end) as APR,
      sum (case monthname when 'MAY' then theval else 0 end) as MAY,
      sum (case monthname when 'JUN' then theval else 0 end) as JUN,
      sum (case monthname when 'JUL' then theval else 0 end) as JUL,
      sum (case monthname when 'AUG' then theval else 0 end) as AUG,
      sum (case monthname when 'SEP' then theval else 0 end) as SEP,
      sum (case monthname when 'OCT' then theval else 0 end) as OCT,
      sum (case monthname when 'NOV' then theval else 0 end) as NOV,
      sum (case monthname when 'DEC' then theval else 0 end) as DEC
    from mytable
    group by itemtype
    order by itemtype
    I need an external application around it or something which will select only 'Type 1'... that is, if all months are each equal to zero, do not include the record in the result set.

    In summary to get a total of zero is not an option, because I could have-15 and + 15 in different columns, in which case, the recording should be displayed.

    Something as simple as... 'not the case (oct = 0 and 0 nov and dec = 0...) at the end is all it seems to me necessary. I thought to add a case for each column clause, but that seems not very effective. Ideas?

    Thanks in advance!
    Mark

    Edit... I know not what follows will work using the MINUS operator, but my actual query is really huge, and I don't want to have to write it twice...
    {code}
    Select
    ItemType,
    sum (case monthname when "JAN" then Val else 0 end) such as JAN,.
    sum (case when monthname 'FEB', then Val 0 otherwise end) by Feb.
    sum (case when monthname 'MAR', then Val 0 otherwise end) like MARS,
    sum (case monthname when "APR" then Val else 0 end) as APR.
    sum (case when monthname 'MAY', then Val else 0 end) either.
    sum (case when monthname "JUN", then Val 0 otherwise end) as JUN.
    sum (case monthname when "JUL" then Val else 0 end) as JUL,.
    sum (case monthname when "AUG" then Val else 0 end) as AUG.
    sum (case monthname when "MS" then Val else 0 end) as MS.
    sum (case monthname when "OCTS" then Val else 0 end) OCT.
    sum (case monthname when "NOV" then Val else 0 end) as NOV.
    sum (case monthname when 'DEC' then Val else 0 end) as DEC
    FROM MyTable
    Group of itemtype

    less

    Select
    ItemType,
    Jan, Feb, mar, Apr, may, June, July, August, Sept, oct, nov, dec
    de)
    Select
    ItemType,
    sum (case monthname when "JAN" then Val else 0 end) such as JAN,.
    sum (case when monthname 'FEB', then Val 0 otherwise end) by Feb.
    sum (case when monthname 'MAR', then Val 0 otherwise end) like MARS,
    sum (case monthname when "APR" then Val else 0 end) as APR.
    sum (case when monthname 'MAY', then Val else 0 end) either.
    sum (case when monthname "JUN", then Val 0 otherwise end) as JUN.
    sum (case monthname when "JUL" then Val else 0 end) as JUL,.
    sum (case monthname when "AUG" then Val else 0 end) as AUG.
    sum (case monthname when "MS" then Val else 0 end) as MS.
    sum (case monthname when "OCTS" then Val else 0 end) OCT.
    sum (case monthname when "NOV" then Val else 0 end) as NOV.
    sum (case monthname when 'DEC' then Val else 0 end) as DEC
    FROM MyTable
    Group of itemtype
    )
    where (oct = 0 & nov = 0 and dec = 0 and jan = 0 and 0 = Feb and mar = 0
    apr = 0 and may = 0 and = 0 jun and Jul = 0 and aug = 0 and Ms = 0
    )
    order of itemtype
    {code}

    Change again... OK, I guess that I am answering my own question here, but I think that by using a WITH to write the main request once clause and then selecting * twice using the MINUS operator between where the second query is where (oct = 0, etc.) is what I need. If anyone has better suggestions, please let me know! Here's the logic of nickname for what I come up with to date...

    {code}
    WITH mainquery as (select all)
    Select * from mainquery
    less
    Select * from mainquery where (oct = 0, nov = 0, etc...)
    {code}

    Thanks again!
    Mark

    Published by: user455268 on March 1, 2012 19:13

    Published by: user455268 on March 1, 2012 19:16

    Hello

    You can do it with a HAVING clause:

    select
      itemtype,
      sum (case monthname when 'JAN' then theval else 0 end) as JAN,
      sum (case monthname when 'FEB' then theval else 0 end) as FEB,
      sum (case monthname when 'MAR' then theval else 0 end) as MAR,
      sum (case monthname when 'APR' then theval else 0 end) as APR,
      sum (case monthname when 'MAY' then theval else 0 end) as MAY,
      sum (case monthname when 'JUN' then theval else 0 end) as JUN,
      sum (case monthname when 'JUL' then theval else 0 end) as JUL,
      sum (case monthname when 'AUG' then theval else 0 end) as AUG,
      sum (case monthname when 'SEP' then theval else 0 end) as SEP,
      sum (case monthname when 'OCT' then theval else 0 end) as OCT,
      sum (case monthname when 'NOV' then theval else 0 end) as NOV,
      sum (case monthname when 'DEC' then theval else 0 end) as DEC
    from mytable
    group by itemtype
    HAVING      MIN (theval)     != 0
    OR      MAX (theval)     != 0
    order by itemtype
    ;
    

    If the values are all 0, then the MIN and MAX will be 0.
    If the MIN or MAX is not 0, the values are all 0.

    This assumes that the combination (itemtype, monthname) is unique, because it is in your sample data.
    If this is not the case, start with a subquery that GROUPs BY itemtype, monthname, so that when you get to the main request, this combination will be unique.

  • Helps the case statement

    Hi Experts,

    I have a date column in the database with date, type of DATA. I want to replace a single date January 1, 1900 "to a space.

    When the case TABLE. COLUMN = January 1, 1900 'and then' ' on the other TABLE. End of column.


    When I wrote this statement... I get an error like

    Union of the incompatible types

    Please let me know where I'm missing.

    Thank you
    V

    Try this:

     
    
    CASE when TO_CHAR(TABLE.COLUMN,'dd-mon-yyyy')='01-JAN-1900'  then ' ' else TABLE .Column End
    
  • DG4ODBC configured and working but receiving ORA-28528 for some columns

    DG4ODBC is configured and working for XE 11 GR 2, but under some circumstances receiving SQL Error: ORA-28528: heterogeneous Services data type conversion error.

    Configuration: DG4ODBC configured for Oracle 11 g 2 using ODBC datasource based on IBM UniVerse ODBC Driver 4.00.04.7346 UVODBC. DLL (25/08/2009), all on the same host 32-bit Windows designed to extract data from remote AIX based IBM/Rockit universe version 10.1 of the database.

    After 3 orders with matching results illustrate the problem:

    Select NO_PROD from bill_mat@dblink, including NO_PROD not in ('15', '20', '24', '6',' 10');

    no selected line


    Select NO_PROD, count (*) from bill_mat@dblink where NO_PROD Group ('15', '20', '24', ' 6', ' 10') of NO_PROD;

    NO_PROD COUNT (*)
    ---------- --------
    6 1
    20 1
    24 1
    9 out of 10
    15 1

    Select NO_PROD in the bill_mat@dblink;

    Error at startup on line 19 of order:
    Select NO_PROD from bill_mat@dblink
    Error report:
    SQL error: ORA-28528: heterogeneous Services data type conversion error
    ORA-02063: preceding line of DBLINK
    28528 00000 - "heterogeneous Services data type conversion error."
    * Cause: Is a type of data Oracle could not be converted to a non-Oracle
    data type, or a type of data non-Oracle could not be converted
    for an Oracle data type. Here are the possible reasons
    the failure of the conversion:
    -overflow problems (in the case of numbers)
    -the limits of length (in the case of strings)
    -invalid values passed in the conversion routines
    * Action: Contact customer support of the agent vendor. If the problem is
    due to differences in size between Oracle and the non-Oracle system.
    It is not possible to convert the value.


    LIST universe queries shows many ' white' values for both fields LST.WO & no PROD that issue when trying to query through DG4ODBC, in the case of the subjects table "BILL_MAT":

    LIST BILL. MAST LST.WO No. LOCK PROD 16:08:44 November 22, 2011 PAGE 11
    BILL. MAST... LST.WO... MOM PROD LOCK

    239912 10
    220419
    247992
    252739
    249709
    239913 15
    184767
    164264
    184666
    164265
    247994
    239914
    251731
    249711
    173760
    239915 20
    242137
    247490
    247894
    254156
    Press a key to continue...



    Interestingly, the output of this test JDBC application is different, including references to "null" values "in white" referred to as with output LIST above:

    import java.sql. *;
    import java. IO;

    public class billmat {}

    Public Shared Sub main (String [] argv)
    {
    try {}
    BufferedReader in = new BufferedReader (new InputStreamReader (System.in));



    //---------------------------
    Connect to the server U2
    //---------------------------

    Chain account = "universe_account";
    String userid = "username";
    String passwd = "password";
    String host = "AIX_Host";
    String url = "jdbc:ibm-u2://"+host+"/"+account+"?tracelevel=5;tracefile=qiang.trace";

    Load the driver and connect to the server
    Class.forName ("com.ibm.u2.jdbc.UniJDBCDriver");
    Connection con = DriverManager.getConnection (url, username, passwd);

    System.out.println ("successful - \n\t*---connexion * \n");


    System.out.println ("1. Select the file Bill. MAT ------------------------");
    testQuery (con);


    con. Close;
    } catch (SQLException e) {}
    System.out.println ("Ex-Message:" + e.getMessage ());
    System.out.println ("ex-code:" + e.getErrorCode ());
    System.out.println ("Ex-SQLState:" + e.getSQLState ());
    System.out.println ("Ex-Next:" + e.getNextException ());
    e.printStackTrace ();
    System.GC();
    } catch (Exception e) {}
    System.out.println ("Exception caught:" + e);
    e.printStackTrace ();
    }
    }


    /**
    * Select CUST. MAT file.
    @param con The JDBC connection object.
    */
    public static void testQuery (connection con)
    throws SQLException
    {
    Statement stmt = con.createStatement ();
    String sql = "select DISTINCT LST.WO, no. PROD, BILL's LOCK. CARPET where LST.WO is not null or not. PROD is not zero. "
    Run the SELECT statement
    ResultSet rs = stmt.executeQuery (sql);

    Results of the first five records
    System.out.println ("\tlist selected columns for the first five records :");
    int i = 1;
    While (rs.next () & & I < 100)
    {


    System.out.println ("\tLST_WO: \t" + rs.getString (1));
    System.out.println ("\tNO_PROD: \t" + rs.getString (2));
    System.out.println ("\tLOCK: \t" + rs.getString (3));

    i ++ ;
    }

    RS. Close();
    stmt. Close();
    System.out.println ("\n\t*---QUERY test has been successfully-* \n");
    System.out.println ("\n\tDisplay Count: \t" + i);
    }

    }



    [root@VM-Linux01 Linux] # java billmat

    -Successful - connection

    1. select in the file Bill. MAT ------------------------
    LST_WO: null
    NO_PROD: null
    LOCK:
    LST_WO: null
    NO_PROD: 10
    LOCK:
    LST_WO: null
    NO_PROD: 15
    LOCK:
    LST_WO: null
    NO_PROD: 20
    LOCK:
    LST_WO: null
    NO_PROD: 6
    LOCK:
    LST_WO: null
    NO_PROD: 24
    LOCK:

    -QUERY test was performed with success-


    Number of view: 7


    The reason column THAT LOCK is included above is because he is using DG4ODBC queryable and presents itself as (null) in the result of the query and provided by SQLDeveloper.

    Considering the above findings, it seems what ORA-28528 IS NOT associated with problems of overflow or limits of length. Instead, some kind of mapping characterset problem here seems more plausible. For example, it seems NULL value returned in the case of the columns LST_WO and NO_PROD of the distant universe database is mapping not properly in the way that a NULL value is represented in the database 11 GR 2. Y at - it % HS_ in file init DG4ODBC value that can be set to solve this problem? I'm not quite sure the range of settings that exist, but try different values for HS_LANGUAGE which did not help.

    There is no problem using Excel MS Query to recover data using the same system DSN and associated ODBC driver on which DG4OBDC the installation program is based on the same Windows computer where DG4ODBC is configured.

    Here are the current settings of DG4ODBC for this instance (initDBLINK.ora):


    HS_FDS_CONNECT_INFO = DBLINK. ODBC
    HS_FDS_TRACE_LEVEL = WE
    HS_FDS_TRACE_FILE_NAME = c: / DG_LOG
    HS_FDS_TRACE_LEVEL = 4
    HS_LANGUAGE = AMERICAN_AMERICA. WE8ISO8859P1
    # Other parameters HS_LANGUAGE attempted to solve the problem are discussed below:
    # HS_LANGUAGE = american_america.utf8
    # HS_LANGUAGE = american_america.al32utf8


    Any guidance would be greatly appreciated!

    Edited by: WileyCoyote 8 March 2012 13:33

    Edited by: WileyCoyote 8 March 2012 13:39

    A gateway trace level 255 (HS_FDS_TRACE_LEVEL0 = 255) could be interesting - also the definition of the source table (how the table is defined in the database of version 10.1 IBM/Rockit universe).

  • Filter column based on another column - OBIEE 11 g

    Hi, I have a strange requirement. I am trying to build a dashboard that allows a user to view the data for the current day, last week, last month or last year. I'll create a presentation called "date_range" variable where the user can choose one of these 4 options.

    On this basis, I defined a column in answers with the following formula:

    Cast
    (
    case
    When 1 = 0 then 'time of the query. "" Date ".
    When @{date_range} {"day"} = 'Day' then Current_Date
    When @{date_range} {'week'} = 'Week' then TIMESTAMPADD (SQL_TSI_DAY,-7, CURRENT_DATE)
    When @{date_range} {"day"} = 'Month' then TIMESTAMPADD (SQL_TSI_DAY-30, CURRENT_DATE)
    When @{date_range} {"day"} = 'Year' then TIMESTAMPADD (SQL_TSI_DAY,-365, CURRENT_DATE)
    of another TIMESTAMPADD (SQL_TSI_DAY,-10000, CURRENT_DATE)
    finish DATE
    )

    Based on the variable 4 presentation, this should give the good 'start date' when to extract data.

    Now, I've added the effective date of the date dimension column. But I need to put a filter on the date dimension date column that says that it is greater than or equal to the above computed column. How do I do that?

    Thank you
    Scott

    I always expect that you are pregnant, but you cannot filter a column on another column. The solution is just to write a formula that returns a literal, so it will be

    When case (your date column) > = (your long form), then put end to 'Y' else ' n

    Then filter this column on 'Y '.

    Kind regards

    Robert

Maybe you are looking for

  • Satellite L875-13D - problem with the installation of the wireless card

    Hello I bought a Toshiba Satellite L875-13D. I installed Windows 7 Enterprise edition. I have a problem with the installation of the wireless card. I have downloaded the driver on Toshiba website, but it does not work. When I run the file .zip and .e

  • How to remove iTunes game play list

    Overtime I open iTunes and connect with the cloud of match, I get songs and playlist duplicate.  I got to select duplicate of cloud songs and delete them.  How to remove duplicates from playlists?

  • Lesson store does not.

    I recently bought the upgrade of garageband so that I can buy piano lessons. Whenever I try to access the store of the lesson, it is "temporarily unavailable". Also, when I'm in Garageband options in my menu bar are all gray-unusable. Help, please.

  • Can I book an appointment

    How can I book an appointment to check my phone?

  • Using network Deskjet 722C Windows 7 problem

    I have a 722C connected to a machine under WinXP SP3, this printer has been shared with another WinXP machine for several years.  I recently bought a HP laptop running Windows 7 Home Edition (64-bit), to which I am trying to add the shared printer.