In the query in Oracle 11 g, how can I refer to the results of different column...

I want to be able to view the results of C1 to another expression of the column C2. I get ORA-00904: identifier not valid "C1", which makes sense. I know that I can repeat the WHOLE very long in my C2 DECODER, but I was wondering if I can register the server many additional cycles to assess the CASE once again.

SELECT [long nested CASE statements] as C1, C2 OF table DECODE(C1,1,'YES','NO')

Thank you very much
AK

Hello

Impossible to refer to the alias at the same or another must therefore repeat the instruction BOX or wrap it in a view online and refer to the alias in that. i.e.

SELECT
    c1,
    DECODE(C1,1,'YES','NO') as C2
FROM
    (
        SELECT
            [very long nested CASE statements] as C1
        FROM
            FROM TABLE
    )

HTH

David

Tags: Database

Similar Questions

  • How can I get a name of table 1, column A, if column B is a negative number and insert the names of table 2?

    How can I get a name of table 1, column A, if column B is a negative number and insert the names of table 2?

    What is the formula?

    You can do this with a column of "index" in table 1, as this assistance:

    The formula in C2, filled to the bottom:

    IF (B =<>

    That increments a counter each time that it finds a negative number in column B.

    In the second table, you can retrieve a list of negative values in this way:

    The formula in A2, filled to the bottom:

    = INDEX (array 1::A, CORRESPONDENCE (LINE (−1, Table 1::C), 0))

    It takes the line number, the formula is activated, subtracts 1 to the header line and look up the result in the column of table 1 C.  If it finds a match, it feeds the line number to the INDEX page with retrieves the value of the column of table 1A.

    To hide the red triangles of signage wrap the IFERROR formula, like this:

    = SIERREUR (INDEX (table 1::A, CORRESPONDENCE (LINE (−1, Table 1::C), 0)),"")

    Of course, you can also simply filter on column B without the need to set up a column from another table or index.

    SG

  • How can I write in a table cell (row, column appear) in a databae?

    How can I write in a table cell (row, column appear) in a database using LabVIEW Database Toolkit? I use Ms Access. Suppose I have three columns in a table, I write 1 row of the 1st column, then 1st rank of the 3rd column. The problem I have is after writing the 1st column of 1st row, the reference goes to the second row, and if I write in the 3rd column, he goes to the 2nd row 3rd column. Any suggestion?

    When you perform a SQL INSERT command, you create a new line. If you want to change an existing line, you must use the UPDATE command (i.e. UPDATE tablename SET column = value WHERE some_column = some_value). The some_column could be the unique ID of each line, date and time, etc.

    I don't know what is the function to use in the Toolbox to execute a SQL command, since I do not use the Toolbox. Also, I don't understand why you don't do a single INSERT. It would be much faster.

  • How can I add a donation page with different levels to give for example $ 250, $150, $50, other

    How can I add a donation page with different levels to give for example $ 250, $150, $50, other.  I'm with Foxy cart... is it possible?

    Since the end of the Muse, you can add texts as the value of the donation with paypal button that would take users to the paypal for the payment site, with Foxy cart you can try the suggestion mentioned here:

    https://Forum.FoxyCart.com/discussion/4417/donation-page-radio-button/P1

    Thank you

    Sanjit

  • How to use break a column during extraction of the results of several columns

    Hi friends
    I am confused a bit I query to retrieve results of 3 tables and I want to use the pause on a column, but it is not work goes I just described my query

    SQL > select a.-, a-, b-, b-, c. - a, b, c, where certain conditions
    When I'm with break on a.-, a..
    the pause does not work

    BREAKING does not support multiple columns. You can break on a.
    http://docs.Oracle.com/CD/B19306_01/server.102/b14357/ch12009.htm

  • How can I pass/add these results in the column of the motion of my hand

    Hello Experts

    I'm working on a subquery. My subquery works very well and gives the results I need. But how do I pass/add these results in the column of the motion of my hand "MGRNAME". Here's my query

    Select pc.c_id 'Project ID',
    CN. C_ID 'Customer ID', cn.c_last "Last Name", "First Name", cn.c_first
    PJ.mgr_id 'ID Manager', 'Project', MGRNAME pj.project_name
    project_consultant PC
    Join them consultant cn
    on (pc.c_id = cn.c_id)
    Join the pj project
    on (pc.p_id = pj.p_id)
    where lower (cn.c_last) = "myers.

    and MGRNAME in
    (select concat (substr (c_last, 1, 20),
    substr (c_first, 1, 20))
    as consultant MGRNAME
    where c_id in (102, 103)
    )

    When I run the above query, I got error.

    Many thanks in advance
    SELECT pj.p_id         "Project ID",
           cn.c_id         "Client ID",
           cn.c_last       "Last Name",
           cn.c_first      "First Name",
           pj.mgr_id       "Manager ID",
           pj.project_name "Project",
           SUBSTR (mgr.c_last, 1, 20) || ' ' || SUBSTR (mgr.c_first, 1, 20) AS mgrname
      FROM project_consultant pc,
           consultant cn,
           project pj,
           consultant mgr
     WHERE pc.c_id = cn.c_id
       AND pc.p_id = pj.p_id
       AND pj.mgr_id = mgr.c_id
       AND mgr.c_id IN (102, 103)
       AND LOWER (cn.c_last) = 'myers';
    

    isotope

  • How can I refer to a variable in the regular expression

    Hello friends,

    I have this Regexp, extract the County code: (971)
    Select regexp_replace (regexp_replace ('05-000971 7910-324324', '\D'),'^ 0 * (971)? 0?') of double;
    It is very good and the need...

    But, thinking about the future, someone may need to remove the country code (961), so it is better if I put the code in a variable, but

    How can I list the County code via a variable since the Regexp:
    declare 
    a varchar2 (15);
    code number := 971;
    begin
    select regexp_replace(regexp_replace('000971 05 7910 - 324324','\D'),'^0*(code)?0?') into a from dual;
    dbms_output.put_line ( a);
    end;
    but it does not work?

    Best regards
    Fateh

    You must link the value of the variable code in the regular expression pattern

    
    select regexp_replace(regexp_replace('000971 05 7910 - 324324','\D'),'^0*('||code||')?0?') into a from dual 
    
  • How to retrieve the parent and the child in different columns when they exist in a single column.

    For example, my table contains data in a column as follows.

    COLUMN_DATA

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

    A00 FOOD 0

    A01 0 DENTAL

    A02 0 PLASMA

    A01A0 CLEAR

    A02A0 CHANNEL

    A01A1 ANTACIDS

    A01A2 ANTACIDS + Napthalone

    A01A3 ANTACIDS + Olive

    A02A1 ACIDS

    A02A2 PLASMAACIDS

    Now, there is a relationship between codes. Four level hierarchy is maintained. EG - A01A1-> A01A0-> A01-> A00 0 0

    I want to receive data as in the format below:

    T4_CODE T4_DESC T3_CODE T3_DESC T2_CODE T2_DESC T1_CODE T1_DESC

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

    ANTACIDS A01A PLAIN A01 DENTAL A01A1 A DIGESTIVE

    A01A2 ANTIACIDES + Napthalone A01A PLAIN A01 DENTAL a DIGESTIVE

    A01A3 ANTIACIDES + Olive A01A PLAIN A01 DENTAL a DIGESTIVE

    A02A1                      ACIDS                                  A02A                        CANAL                     A02                    PLASMA                         A                ALIMENTARY

    A02A2 PLASMAACIDS A02A A02 PLASMA CHANNEL HAS DIGESTIVE

    So we must derive the level four of codes and their descriptions in different columns.

    Any help is really appreciated.

    Thanks in advance.

    And I got a simpler and more efficient way to do ds.

    with t as

    (select text

    case

    When substr (text, 4, 1) = ""

    then rtrim (substr (text, 1, 3), ' 0')

    of another rtrim (substr (text, 1.5), ' 0')

    end of the code

    , substr (text, 7) descript

    of lc_load

    )

    t2 as

    (select

    case length (t.code)

    When 1

    then 1

    When 3

    then 2

    When 4

    then 3

    When 5

    then 4

    end lvl

    , t.*

    t

    )

    Select t2_4.code

    t2_4.descript

    t2_3.code

    t2_3.descript

    t2_2.code

    t2_2.descript

    t2_1.code

    t2_1.descript

    of t2_1 t2

    Join t2 t2_2

    on t2_1.code = substr (t2_2.code, 1, 1)

    Join t2 t2_3

    on t2_2.code = substr (t2_3.code, 1, 3)

    Join t2 t2_4

    on t2_3.code = substr (t2_4.code, 1, 4)

    where t2_1.lvl = 1

    and t2_2.lvl = 2

    and t2_3.lvl = 3

    and t2_4.lvl = 4

  • How can I turn off autoforwarding to a different e-mail account?

    My Thunderbird email goes to two places. My Thunderbird account and another account. How can I disable the other?

    As already said, there is no distinction between a Thunderbird account. E-mail accounts are issued by providers of electronic mail and Thunderbird's email client software and not a supplier.

    It is possible to create a filter in Thunderbird to forward incoming mail. If that's what you were doing, remove the filter.
    The most logical way to do this is with your email providers server. If you did send, sign in to your account to your web e-mail providers page and put the transmission.
    Only you know how your insider sent in the first place.

  • How can I start my iMac from a different drive?

    MY SSD drive seems to be kaput, but my HD can also be used as a startup disk. How can I force the iMac from the HD?

    Hold down the Option key when starting. You will be presented with a list of bootable disks to choose.

  • How can I get a search result to activate a new tab?

    In previous versions of Firefox that I used, whenever I typed a word or phrase in the search box in the upper right corner, the result automatically activated and appeared as a new tab (he could appear as a new window browser FF all together, I don't remember for sure).

    In the version I use (6.0.2), whenever I have a search using said search box, the result is automatically displayed on the current page, I'm on. It changes the page I'm on.

    How can you change or where is the parameter that has to be changed (I looked in 'tool', then '' options' and have not found a setting/choice for this action)?

    I would greatly appreciate help on this, since I have concluded that it is frustrating for some time. This is the first time, I looked for a solution with you' well all. Your help would be greatly appreciated.

    Thank you

    David

    You can do one of the following:

    1. After you enter your search term in the search bar, you can middle-click or Ctrl + left - click on go (magnifying glass) button in the search bar (= Middle-click (press the scroll of the mouse wheel).)
    2. You can change a preference to always open a new tab when searching from the search bar by pressing the Enter key only (not the URL/address bar):

    If this answer solved your problem, please click 'Solved It' next to this response when connected to the forum.

    Not related to your question, but...

    You may need to update some plug-ins. Check your plug-ins and update if necessary:

  • How can I access a repository of two different system work?

    Please let me know how I could access a repository of two different system running studio odi client. I am able to access the master repository, but not the working repository.

    Repositories of work are always associated with a same master repository. If you can access the control, you will be able to access its repositories of work as long as your security config allows for your user. Maybe it's that you set only a connection to the master repository only on your connection customer of Studio profile. Change the connection (from the connection dialog) profile and simply choose the working repository you want to connect.

  • How can you save session hearing on a different hard disk, sent via dynamic links to first?

    I am a Mac user. I train to a PC user to edit my audio.

    After the edict of sequences in CEP I send it via dynamic links to hearing make the audio changes then new return to CEP.

    How can I save the project/session of my Mac on a drive external hard shared for the PC user edit in Audition?

    I tried to send the CEP project via dynamic link to hearing, then opening audio files in Audition, then with the video showing in hearing - file > export > Session > checked "save copies of associated files" & chose the external hard drive that we share. No dice. External transfer to the computer and open the hearing session he has no related video and audio files that I had opened are not there. Essentially, this is an empty session.

    Help!

    Hi... basically dynamic link is not what you want if you want to send it to someone else for sound editing, as I can tell. I think the best option for you would be to select 'Export DV Preview Video' rather than 'Send by Dynamic Link' (under 'Edit in Audition'), which I think should export a video resolution low - ish, and the audio files and XML for hearing.

    Hope it is helpful

  • How can I move a folder to a different drive

    My external HD with all my photos seems to be corrupted, I bought another pilot. How can I move the entire library to the new drive... I do not see the new drive in Lightroom

    Changes are lost if you can't point LR to a good copy of your images.

    If you made a backup of your external hard drive, you can copy this backup on your new drive; Then, as long as the folder structure is the same the old disk, you point just LR on the top level of the new disk files in folders, and LR Panel will reconnect everything for you.

  • Problems with separation of the results in different lines. Group question?

    Hi all!

    I have a table that looks a bit like this:
    Pallet          Status          Number          Time
    A          MoveIn          48          11:11
    A          Pick          -1          11:11
    A          Pick          -1          11:12
    A          Pick          -1          11:12
    A          MoveOut     45          11:13
    A          MoveIn          45          18:20
    A          Pick          -1          18:23
    A          Pick          -1          18:23
    A          Pick          -1          18:23
    A          Pick          -1          18:24
    A          MoveOut     41          18:25
    A          MoveIn          41          21:31
    A          Pick          -1          21:55
    .....
    It's exploitation forest pallets that is moved to a station and then number of boxes is picked off the coast. (To make it more simple, I only show a palette in above example.)

    I would like to introduce the result with one row for each time that the palette were at the station, as:
    Pallet          Picked          Time
    A          3          11:11
    A          5          18:20
    A          ....          .....
    This means that the same palette can be showned on several lines, as happened to the station several times. I tried several different 'GROUP BY', but I can't get it to work.
    For example, I tried to group by time, but this fails if a pallet is moved twice per hour or if the boxes are picket at different times (for example, first box picked 09:59, last box 10:01)

    Anyone has a suggestion how to fix this problem?

    Thanks in advance and greetings / Anders from Sweden

    Hej, Anders,

    Can you explain what defines a group?

    Looks like you say that a group is a subset of a palette. If we organize all the lines for a palette in the order of time, a new group starts whenever we have a line where status = 'MoveIn. In other words, a group consists of a line with status = "MoveIn" and all the lines immediately after, in order by time, up to, but not including, the next row with status =-"MoveIn. Is this fair?

    If so, you can use the function COUNT (or SUM) Analytics to see how many lines with status = "MoveIn" have already taken place, in order by time, like this:

    WITH     got_grp          AS
    (
         SELECT     pallet, status, time
         ,     COUNT ( CASE
                             WHEN  status = 'MoveIn'
                       THEN  1
                         END
                    ) OVER ( PARTITION BY  pallet
                                ORDER BY          time
                        )           AS grp
         FROM    table_x
    )
    SELECT       pallet
    ,       COUNT ( CASE
                      WHEN  status = 'Pick'
                    THEN  1
                  END
                )          AS picked
    ,       MIN (time)          AS start_time
    FROM       got_grp
    GROUP BY  pallet
    ,            grp
    ORDER BY  pallet
    ,            grp
    ;
    

    If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

    This assumes that the combination (palette, time) is unique. Your sample data includes:

    Pallet          Status          Number          Time
    A          MoveIn          48          11:11
    A          Pick          -1          11:11
    

    I suppose that you decide to simply not show the full time, and your data is really something like:

    Pallet          Status          Number          Time
    A          MoveIn          48          23-Sep-2011 11:11:01
    A          Pick          -1          23-Sep-2011 11:11:08
    

    Otherwise, how do you know if these two lines are in you the same group or not? You may need to add a break to the analytical ORDER BY clause. For example, if you say "ORDER BY time, * status *", then, if the above two lines really have exactly the same time, to the second, then one with status = "MoveIn" would be considered as prior to the line with status = 'Choose'. "

Maybe you are looking for