How to generalize the statement below box?

I have below logical case that I need to remove the coding hard of the year field based on the ranges of the year below. Perhaps using another function and make more generic?

insp_dt = Date
po_id = Varchar2 (5)
SELECT 
 DISTINCT DECODE(SUBSTR(UPPER(a.PO_ID),1,1),'S','SP','U','SU','F','FA','H','HO')||
    CASE 
  WHEN TO_CHAR (a.insp_dt,'YYYY') < 1999
            THEN '9'
  WHEN TO_CHAR (a.insp_dt,'YYYY') between 1999 and 2008
            THEN '0'
  WHEN TO_CHAR (a.insp_dt,'YYYY') between 2009 and 2018
            THEN '1'
  WHEN TO_CHAR (a.insp_dt,'YYYY') between 2019 and 2028
            THEN '2'
  WHEN TO_CHAR (a.insp_dt,'YYYY') > 2028
            THEN 'x' END ||substr(a.po_id,2,1) AS season_year
 FROM MAP.finished_goods_audit a
Expected result for season_year is:

SP06 (SP + 0 + 6 obtained from the instruction box for spring 2006)
SU10 (SU + 1 + 0 obtained in the instruction box for summer 2010)
HO99 (HO + 9 + 9 from the instruction box for holiday 1999)

What picking the third character in the string of the YEAR?

SUBSTR(TO_CHAR(a.insp_dt,'YYYY'),3,1)

Tags: Database

Similar Questions

  • How to create the object rectangular box with a pure action script.

    How to create the object rectangular box with a pure action script?

    I think, it can be done through the clip library, but I'm not sure. Please, I want to take the suggestion to create a rectangular box as a script through

    Take a new file and write about the first image the code below, it works fine:

    var rect = new Shape();
    rect.graphics.beginFill (0xFF0000);
    rect.graphics.drawRect (0, 0, 100,50);
    rect.graphics.endFill ();

    var MC = new MovieClip();
    mc.addChild (rect);
    addChild (mc);

    If this doesn't solve your problem then paste the error you get

  • Using Windows Mail - how to make the smaller Options box so I can see the bottom and be able to act on it?

    Computer is a 32-bit Dell XPS * SP2 Windows Vista (Home Premium), Internet Explorer 9 Panda anti-virus

    Nothing new and NO change has been made.

    Using Windows Mail - how to make the smaller Options box so I can see the bottom and be able to act on it?

    Even when I hide the taskbar I always can't NOT see the background.  Thanks in advance for any help. It drives me crazy.

    Set your resolution to be higher.  Right click on your desktop, go to personalize, then choose the resolution down.  Set it to the highest setting.

  • How to get the State of the button?

    I want to know how to get the State clicked the button? If it is clicked State or State clicked?

    For ex: I have the following code...

    {( < composants: IconButton id =»bold_btn"largeur =»22" icône =»@Embed('/assets/bold.png')"click ="onBoldClick ()"enabled =" {}this.loadCompleted}"toggle ="true"/ >

    How to find if the "BOLD" button is checked or not?

    this.bold_btn. ???

    Please mark

  • How to make the State "out-of-box' again on my Satellite L653-12J

    Hello

    I have been in charge of research and following the instructions but all have failed.
    I'm selling my Toshiba Satellite computer laptop L653-12J with Windows 7 and I would like to clean the hard drive of all the data added to have it back to its out of the box state.

    Please advise me how?
    Thanks and regards,

    Kamal

    Hello Kamal

    How to install the recovery image, which you can read on follow Toshiba document -.
    http://APS2.toshiba-tro.de/KB0/HTD1303440001R02.htm

    It works for you?

  • Function within the statement call box SQL

    I have a procedure with many cases not to validate inside statements that compare the data in a table and fill in a description of the error of the dates. (snip of the size of the code below)

    create or replace procedure "PROC_TEMP_UPDATE"
    is
    begin
    update temp_update
    set error_desc = 
        CASE
        WHEN (error_desc != 'MATCH')
            THEN 'PCFN/TCN combo not found in destination table.'
        WHEN (error_desc = 'SKIP')
            THEN NULL
        WHEN (ge_ata is null and az_ata is not null)
            THEN 'Enter GE ATA Date before entering AZ ATA Date.'
        WHEN ((ge_ata is not null and az_ata is not null) and ge_ata > az_ata)
            THEN 'GE ATA Date cannot be greater than AZ ATA Date.'
           end proc_temp_update;
    
    
    

    Instead of having to enter the bottom 2 when reporting for each date, I created these functions:
    (Function 1: check if Date1 is null and Date2 is not.)
    Function 2 these two dates are not null, check if Date1 is greater than Date2.)

    function Is_D1_NULL
                (Date1  DATE, Date2 DATE)
                return BOOLEAN is
    
          result     BOOLEAN := FALSE; 
       begin 
          if (Date1 is null and Date2 is not null) then  
             result := TRUE; 
          end if; 
          return (result); 
       end Is_D1_NULL;
    

    You cannot use Boolean in SQL queries.  You must modify your function to return something like Y/N or 1/0 and assess against that.

    That said, move the engine of SQL and PL/SQL is, relatively speaking, cheap, so I let just the comparisons as they are in instruction box instead of calling a function.

    John

  • How to save the State of the checkbox in the database

    HELLO everyone again ;)
    I want to save the State of the checkbox (checked or unchecked, true or false) in the database.

    For example, if the user, check the box and press the validate, then this value (check = true) should be stored in the database (true), and when the user only view this value in another page jspx, then this value should be displayed: checked (true)

    How can I do? What are the data type in the database object and the entity to do this?

    Thank you.

    This could also help
    http://download.Oracle.com/otn_hosted_doc/JDeveloper/11gdemos/ADF_Insider_Essentials/ADF_Insider_Essential_YesNoRadio/ADF_Insider_Essential_YesNoRadio.html

    concerning
    Grant

  • How to change the stop dialog box?

    So I will try to change the image of the banner of the stop in Vista dialog box, would anyone here happen to know how to do this (or if it is possible)?

    This:

    http://www.vistarevisited.com/wp-content/uploads/2007/12/quick-shutdown-thumb.jpg
    I checked a few dll in System32 (shell32, Shellstyle.dll, shgina [because the xp shutdown dialog box is apparently 'msgina.dll']) but I don't see anything that had to do with the shutdown dialog box. I thought that it would be better to ask before going through each file in system32.
    Any information would be very helpful, thank you.

    (btw, I searched google and bing nothing works, that's why I ask. "I doubt that many people would want to do this.)

    Thanks for your reply.

    I already searched the internet for the software, and I found a few programs that allow me to edit .dll files (which is what I assume that contains the info dialog box). I want to know is what file contains the dialog box information.

    EDIT: found, I guess this thread can be closed now.

    For future reference, the banner of the shutdown dialog box (among others) is located in C:\Windows\Branding\Basebrd\basebrd.dll

    Now I have my Vista Home Premium set up to look as if it was the pinnacle. : D

    including the logo to the login screen (shich is contained in the same file, the file number 120 in the Bitmaps folder.

  • How to reset the State of package variables in all sessions connected (without requiring a disconnection and a connect) if they are reset in one of connected sessions.


    Hi people,
    Need help, the example requires that the value of packet data 'g_var' must be updated in the session/s connected everywhere without the session/s to be disconnected and reconnected.
    Here's the scenario:

    I created a table my_table having the pair name / value.
    A variable with global package "g_var' in his body and a get accessor method to access g_var variable from the outside world.
    This variable g_var is initialized within the block of the entry into force of the package and retrieves the current value of the variable from my_table.
    When I update the value in the table a trigger on my_table would reset the State of the package and therefore g_var to the most recent value in the same session
    All is well so far since the change in value is reflected in the current session, but if I've already connected session/s
    and I'm trying to retrieve the value of "g_var", it is not updated in already connected sessions and remains the same before the update.
    Can U help please how can I update this value in a session/s connected without having to disconnect and reconnect.
    because if I disconnect and reconect the existing sessions, it seems to show the updated value.

    Thanks in advance.

    Kind regards
    Gaurav Rajput

    Here are the Scripts:


    drop table my_table;
    create table my_table
    (
    my_variable_name varchar2 (100),
    number of my_variable_value
    );

    create or replace package my_package as
    Function get_g_var return number;
    end my_package;
    /

    create or replace package body my_package as
    number of g_var;

    Function get_g_var return number is
    Start
    Return g_var;
    exception
    while others then
    lift;
    end get_g_var;

    procedure init (my_passed_name varchar2) is
    Start
    Select my_variable_value in the g_var from my_table where my_variable_name = my_passed_name;
    exception
    while others then
    raise_application_error (-20004, "I got an error during Init");
    end init;

    Start
    init ('$'); -This is a call to time when the package is loaded into the memory of session
    exception
    while others then
    raise_application_error (-20003, 'Error in my_package');
    end my_pACkage;

    /
    create or replace TRIGGER my_trigger
    BEFORE DELETE OR UPDATE
    ON my_table
    FOR EACH LINE
    declare
    number of my_ret;
    Start
    DBMS_SESSION.modify_package_state (DBMS_SESSION. RESET);
    exception
    while others then
    lift;
    end my_trigger;

    /

    -It is initially set to null
    insert into my_table values ('DOLLAR', 62);
    commit;

    -test value for first time to package loading (62 views)
    Select * from my_table;

    Set serveroutput on

    declare
    my_variable varchar2 (100);
    BEGIN
    my_variable: = my_package.get_g_var;
    dbms_output.put_line ($my_var);
    END;

    -run the same block of end to start in another session it shows 62. All is well so far
    -check if the value after the update in the same session (shows 38), also check in another before the connected session as well (shows 62 and not 38)
    Update my_table set my_variable_value = 38 where my_variable_name = "DOLLAR";
    commit;

    Select * from my_table;

    Set serveroutput on

    -It displays 38 in this session, but there in an already connected session 62 and only after you log out shows 38
    declare
    my_variable varchar2 (100);
    BEGIN
    -my_variable: = my_package.g_var;
    my_variable: = my_package.get_g_var;
    dbms_output.put_line ($my_var);
    END;

    Package variables are stored in the private memory (PGA). The value is not visible in the session. A package variable is therefore not approach appropriate to your problem. You can look at in the context of the Application, as Solomon has said.

    http://docs.Oracle.com/CD/B28359_01/network.111/B28531/app_context.htm#CIHFJHCG

  • How to find the Photoshop product box series

    Hello

    I have Photoshop product box, but there is no serial number on the inside? How I activate the product?

    To locate the serial number:

    http://helpx.Adobe.com/x-productkb/global/find-serial-number.html

    If the software is installed on a machine in your office, then you might be able to acquire the serial number of this one.

    If it's a Windows machine, and then try running Belarc Advisor

    http://www.Belarc.com/free_download.html

    For a Mac, you can try:

    https://Mac-product-key-Finder.com/

  • How Illustrator calculates the height of box Em?

    I am trying to determine how Illustrator calculates the basic position of the top of the a Point text object bounding box.  She seems to be the same distance as an object of text box with the game setting of first base to box Em height line.  I just do not know what assets within the scope of the police which matches.  Help of the Illustrator defines it as:

    "The top of the box em in Asian fonts touches the top of the type object. This option is available regardless of the preference show Asian Options. »

    For some fonts, this distance seems to be near the pole of the police, but this is not true for each font.  The clues how Illustrator calculates it?

    metric-example.png

    Here you go

    var idoc = app.activeDocument;
    var itext = idoc.selection[0];
    
    var top = itext.position[1];
    var base = itext.anchor[1];
    
    alert('Em? size: ' + (top-base));
    
  • How to format the data below


    Hi, I have the following data in the rows, but how can I format in below format using SQL or PL/SQL

    Examples of data


    create table test_temp (invoice_num varchar2 (20), gl_date date, amount, type_of_inv varchar2 (2));

    insert into test_temp values ('1000765', 30 June 2013 ", 800," DM");

    insert into test_temp values ('1001767', 1 July 2013 ', 1000, "DM");
    insert into test_temp values ('1001789', 3 July 2013 ', 1000, "DM");
    insert into test_temp values ('1001874', 10 July 2013 ', 500, "DM");
    insert into test_temp values ('1001876', 11 July 2013 ', 500, "DM");

    insert into test_temp values ('1001768', 1 July 2013 ', - 800, 'CM');
    insert into test_temp values ('1001769', 2 July 2013 ', - 1500, 'CM');
    insert into test_temp values ('1001783', 2 July 2013 ', - 1000, 'CM');

    insert into test_temp values ('1001875', 11 July 2013 ', - 500, 'CM');


    Select a.* from (select gl_date, invoice_num, type_of_inv, quantity of test_temp where type_of_inv = 'DM'
    Union
    Select invoice_num, gl_date, type_of_inv, amount of test_temp where type_of_inv = 'CM') a
    order of a.type_of_inv, a.gl_date, a.amount


    invoice_num gl_date amount type_of_inv
    1001768 1 JULY 13-800 CM
    1001769 2 JULY 13 CM-1500
    1001783 2 JULY 13-1000 CM
    1001875 11 JULY 13-500 CM
    1000765 30 JUNE 13 DM 800
    1001767 1 JULY 13 DM 1000
    1001789 3 JULY 13 DM 1000
    1001874 10 JULY 13 500 DM
    1001876 11 JULY 13 500 DM

    -output must be below the order by gl date

    Choose the cm and apply against DM order by gl date


    1001768 CM is applied on DM 1000765 amount - 800 + 800 = 0

    CM 1001769 is applied on DM 1001767 amount - 1500- + 1000 = 500

    CM 1001769 is applied on DM 1001789 amount - 500 + 1000 = 500

    CM 1001783 is applied on DM 1001789 amount-1000 + 500 = - 500

    CM 1001783 is applied on DM 1001874 amount - 500 + 500 = 0

    CM 1001875 is applied on DM 1001876 amount - 500 + 500 = 0

    The logic is less than

    In the test_temp table, I have my two CM and DM stored,

    I have to write a query, or a PL/sql program to get the below output.
    The logic to retrieve the output here is as follows

    Get the first CM and get the first DM to add the amount of CM with amount of DM up to its sum (amount of cm + size DM) = 0
    with less date GL

    who will give me the first production line

    1001768 CM is applied on DM 1000765 amount - 800 + 800 = 0, now I can take the next CM because its amount is zero


    get the next CM with less gl date to apply against the DM

    1001769 CM is applied against 1001767 with amounts - 1500- + 1000 = 500

    then my amount after worn here is still not zero if the same note of credit (on the left - ve amount of CM)
    must be applied on the next DM


    1001769 CM is applied against 1001789 with amount (-500 + 1000) = + 500

    so in this case (+ amount is from left to right on DM), get the new CM

    1001783 CM must be applied on DM even because always the amount was left with amounts DM 1001789 (-1000 + 500 = 500)

    now, in this case - ve amount is left cm

    so even CM must be applied on the next DM

    1001783 is applied on the next 1001874 DM with amounts-500 (to the left of the previous) + 500 (amount of this DM) = 0
    (In this case sum is zero, so I can choose new CM)

    get next CM 1001875 and applied on the next 1001876 DM with amounts-500 + 500 = 0

    Hope this is clear, or let me know please

    Thanks a ton of Frankkulash...

  • Pls hlp! How to reset the State back to a page...

    I have implemented a multi page doc and have created beween navigation pages via a button at home.

    step 1 click the icon home and step 2 that a wheel appears with a choice of pages to go then.

    Everything works fine the 1st time I go to each page, but the back for the 2nd time that the wheel is always in the center of the page. I want that this reset whenever I go to each page.

    See below link to my example – hope that all makes sense.

    https://www.dropbox.com/s/td6274sm8t74955/test%20wheel_v.indd

    Thank you very much

    Claire

    The first action the button must be going to the State 1. Who clog the DSO as it appears that the first State is empty. Ok.

    For the second action use go to url and use the navto command to access the article/page you need.

  • How to keep the State page apex value after connection page

    Does anyone know to keep the State in a page of the apex, when I go to another page and come back? He keeps all the values entered into the fields, it seems that the gaps?

    I have 5 regions and each region have elements: text fields, selectors of dates, popup lov, field numbers, text box and view point only. When I go to the next page with redirect and return I see popup lovs values and values of one or two display items only. The values of the other text fields, dates selectors and the display just empty.

    Thank you everyone can help. Thank you.

    Kind regards
    Dragan

    Hello

    This element only display recording session state?
    Checks the attributes of the element.

    Kind regards
    Jari

    -----
    My Blog: http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai

  • How to save the State of a flash cs5 to iphone app

    Hello

    I was wondering if anyone could tell me if it is possible to somehow save the State of a flash application is able to pick up where he was arrested after being closed. For example, is it possible for a user to save games in an iPhone game written in Flash? If Yes, could someone point me in the right direction on the place where to read on how to do it.

    see you soon

    Brendan

    http://www.Adobe.com/devnet/flash/articles/saving_state_air_apps.html

Maybe you are looking for