eHref and a Case statement in Sql query

Hi all

I have a select statement that looks like this:

Select

case when dbms_desc = 'ORACLE' and then ' < a href = "f? p = & APP_ID.:115: & SESSION. : & DEBUG. : & PAGE. : 53 "> #DATABASE_NAME # < /a > '

When dbms_desc = "SQL SERVER" and then "< a href =" f? p = & APP_ID.:115: & SESSION. : & DEBUG. : & PAGE. : 59 "> #DATABASE_NAME # < /a > '"

Another null

end as database_name,

Decode(databases.inactive_flag,'Y','Yes','N','No',null) inactive_flag, servername,.

application name, decode(application.critical_flag,'Y','Yes','N','No',null) critical_flag,

Decode(application.inactive_flag,'Y','Yes','N','No',null) app_inactive_flag, databases.database_id

application, database, server, application_database_int

where databases.database_id = application_database_int.database_id (+) and

application_database_int.application_id = application.application_id (+) and

databases.server_id = server.server_id and: P54_DBMS_DESC = dbms_desc and

(upper (database_name) like '%' | upper(:P54_DATABASE_NAME) |) '%')

order by database_name

This query creates a report of classis. The result is the following:

I wanted to see was the name of the database in the first column in the form of links. What is the problem with the query?

INKA says:

I use Apex v5 and I don't see where I can put the attributes column for the column database_name "display under" for "Standard report column.

In the designer of the Page, select the report column in the browser on the left pane and change the properties in the property editor on the right, the column definition Type plain text and special escape characters No. See the Release Notes for the naming of the differences column property in the APEX 5.0.

Tags: Database

Similar Questions

  • Excel and the CASE statement.

    Hello Experts,

    I use a CASE statement on the column of CHAR type as follows:

    CASE WHEN Sales.Ret = 'Y' THEN 'Return' END of OTHER 'new '.

    It gives an error: Odbc driver returned an error (SQLExecDirectW).

    Whereas, when I use another CASE statement with column Numrical it works perfectly.
    CASE WHEN Sales.Amount < END If NOT 100 40 THEN 40

    Am I missing an Excel data source definition related to the CHAR data type?

    My source is MS Excel 2003 and OBIEE 10.1.3.4.1

    Thank you for any comments, help.

    ~ Ash

    PS: the details of the error are the following:*.
    Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 16001] ODBC error state: 37000 code:-3100 message: error [Microsoft] [ODBC Excel Driver] syntax (missing operator) in query expression ' case when T46. [Retirement] = "Y" then "known" other "new" end "... [nQSError: 16014] Prepare the SQL statement failed. (HY000)
    Publ. SQL: SELECT Sales.Tran_date, saw_0, CASE WHEN Sales.Ret = 'Y' THEN 'Return' ELSE 'New' END saw_1, network. "" Network name "saw_2, Sales.Amount saw_3 FROM P4UD ORDER BY saw_0, saw_1, saw_2

    Sorry, the button is 'Ask DBMS' (biee 10g)

  • Use the CASE statement in a query of LOV

    Hello

    I wrote a select statement to be used in my list of values query, and it works fine when I run with SQL Developer. But when I put it in the LOV I get the LOV query is invalid error message. Here's the query I use:
    select 
        case when nt.COMMON_NAME is not null then nt.COMMON_NAME || ' (' || nt.TAXON_NAME || ')'
            else nt.TAXON_NAME
        end display_species
       ,case when nt.COMMON_NAME is not null then nt.COMMON_NAME || ' (' || nt.TAXON_NAME || ')'
            else nt.TAXON_NAME
        end return_species
    FROM NBN_TAXON nt
    WHERE lower(nt.INPUT_CATEGORY) = decode(lower(:P312_TAXON_GROUP_ADD), 'fish', 'fishes', lower(:P312_TAXON_GROUP_ADD))     
    order by 1;
    If the CASE statement is the source of the problem?

    Hello

    Try to remove the colon semi at the end.

    See you soon

    Ben

  • CASE statement in a query

    I have a following business rule:
    SELECT DISTINCT Clnt_id
    IN saverr
    WHERE trim (cove_cd) IN ('I' ' d "," R "" ")
    AND (trim (med_cd) IN ('B ','d ', 'X', ',' don't))
    GOLD trim (spend_down_cd) = 'Q')
    OR pt_a <>'000000';

    I must point out above clients as 'Y' else ' n

    I have written following statement but doesn't seem to work for <>clients '000000' pt_a.

    SELECT client_id, nvl(cove_cd,'$'), nvl(med_cd,'$'), nvl(spend_down_cd,'$'), nvl(pt_a,'$').
    CASE

    WHEN pt_a not in ('000000') or
    (TRIM (nvl(cove_cd,'$')) IN ('I' ' d ',' R' "))
    AND (trim (nvl(med_cd,'$')) IN ('B ','d ', 'X', ',' don't) GOLD trim (nvl(spend_down_cd,'$')) = 'Q'))

    THEN
    « Y »
    ANOTHER "N".
    END as dual_eligible
    IN saverr
    where pt_a like "000000";

    I always get the customers marked as "n" for pt_a as '000000'

    Any help is appreciated.

    Concerning
    Jay

    Published by: J1604 on July 17, 2012 15:26

    a little lost in all the ANDS and ors, and where to go the parenthesis.

    might be easier to work if you try something like that

    /* Formatted on 7/17/2012 4:58:14 PM (QP5 v5.185.11230.41888) */
    WITH T
         AS (SELECT client_id,
                    TRIM (NVL (cove_cd, '$')) cove_cd,
                    TRIM (NVL (med_cd, '$')) med_cd,
                    TRIM (NVL (spend_down_cd, '$')) pt_a
               FROM saverr)
    SELECT t.*,
           CASE
              WHEN pt_a NOT IN ('000000')
              THEN
                 'Y'
              WHEN     pt_a = '000000'
                   AND cove_cd IN ('I', 'D', 'R')
                   AND med_cd IN ('B', 'D', 'X', 'M', 'N')
              THEN
                 'Y'
              WHEN pt_a = '000000' AND spend_down_cd = 'Q'
              THEN
                 'Y'
              ELSE
                 'N'
           END
              col
      FROM t
    
  • case statement in sql advanced

    How to use the instruction box in advanced sql. Example if quarter = 1 I select jan, Feb and March months of table

    Hello

    With the help of the presentation variable, something like that.

    {- case when 1 =@{Quarter_Presentation_Var_Name} then end Month_Num_col_Name<>

    I hope this helps.

    Concerning
    Young

  • definition of variables in packages and using the same variables in charge Plans as a case statement in Odi

    Hello

    I am trying to use a global variable 'Global.test' in my ODI "pkg_test" package and step declaration type as a variable that is defined with the value 1 when my package evaluates the condition successfully run and with 0 if the fails.now condition I will carry out the same "pkg_test" package in my load "LP_TEST" and using the variable 'Global.test' Plan as a case statement in terms of load "LP_TEST".

    It's workload Odi is unable to understand the value of the variable 'Global.test', which is defined in my pkg 'pkg_test' and my case statement is put down in my care Plan.

    Thank you

    Hi Santosh Pradhan,

    What kind of story do you have in your variable?

    If you have not selected any antecedent, the scope of the variable is limited to the session. As the execution of the package is a session in its own (independent of the workload performance), the value of the variable is not accessible after his execution.

    You can also try assigning / updating of the value of the variable directly from your plan, instead of in the package:

    It will be useful.

    Best regards

    JeromeFr

  • Problem SQL querry (case statement...)

    Hi to everyone who reads this.

    I have a huge problem (at least for me) with a SQL I try to write in Oracle forms6 (yes I know... old app).

    OK, here it goes...

    We have a table like:
    create table temp (
      year     number 
      month    number,
      konto    number,
      DEBET    number, 
      KREDIT   number,
      date_tr  date,
      ind      number
    );
    The data in the table are:
     YEAR        MONTH    KONTO      DEBET     KREDIT DATE_TR  IND
    ---------- ---------- ----- ---------- ---------- -------- -
          2011          1 12101   4674,32           0 05.06.11
          2011          6 12101  -4674,32           0 05.06.11 R
          2011          6 12182   4674,32           0          R
    Now, to explain a little what I want to do...
    case when p_date > NVL(date_tr,'01012004') then
    date_tr is null;
    else
    ind is null
    end
    What I need is when p_date is entered by a user SQL should check if the date is less or greater than date_tr...
    in this case it should show only the record that has a null value in date_tr cullum.

    Or if it isn't... it should display records which is null in ind cullum.


    The main problem is that I do not know how to write the case statement in SQLs where clause... maybe someone can give me a hint
    or a partial code how do I solve this problem.

    Any ideas would be greatly apreciated.

    Thanks to you all!
    SQL> with temp as
      2  (select 2011 YEAR,1 MONTH, 12101 KONTO, 4674,32 DEBET, 0 KREDIT, to_date('05.06.11','DD.MM.YY') DATE_TR, NULL IND from dual union all
      3  select 2011, 6, 12101, -4674,32, 0, to_date('05.06.11','DD.MM.YY'), 'R' from dual union all
      4  select 2011, 6, 12182,  4674,32, 0, NULL, 'R' from dual
      5  )
      6  SELECT *
      7  FROM   temp
      8  WHERE  CASE
      9           WHEN To_date('&dt, 'DD.MM.YYYY') > (SELECT MAX(date_tr)
     10                                               FROM   temp) THEN To_char(date_tr)
     11           ELSE ind
     12         END IS NULL;
    Enter value for dt: 30.06.2011
    
          YEAR      MONTH      KONTO       4674      DEBET     KREDIT DATE_TR   I
    ---------- ---------- ---------- ---------- ---------- ---------- --------- -
          2011          6      12182       4674         32          0           R
    
    SQL> /
    Enter value for dt: 30.05.2011
    
          YEAR      MONTH      KONTO       4674      DEBET     KREDIT DATE_TR   I
    ---------- ---------- ---------- ---------- ---------- ---------- --------- -
          2011          1      12101       4674         32          0 05-JUN-11
    
    SQL>
    
  • SQL query to retrieve only numbers to a string variable

    Dear all Experts,

    I have a requirement in one of my projects where I need to extract only the numbers present in the variable.

    for example:

    BANK_ACCOUNT_NUMBER = 12345-67890';

    BANK_ACCOUNT_NUMBER = 12345 67890';

    BANK_ACCOUNT_NUMBER = "123.456.7890";

    BANK_ACCOUNT_NUMBER = 123-A456BC7890D';


    In all these cases, I need to retrieve only numbers such as BANK_ACCOUNT_NUMBER = 1234567890 and I am looking for SQL query only.


    Please suggest me the query how to extract numeric values from varchar variable.



    Thank you

    Knockaert

      select regexp_replace('123-A456BC7890D','[^0-9]') from dual;
    

    See you soon,.

    Manik.

  • Clarification of the SQL query in 2 day + Guide APEX

    I worked through the Oracle Database Express Edition 2 day + Application Express Developer's Guide, and try to decipher the SQL query in Chapter 4 (building your app).

    The code is:

    SELECT d.DEPARTMENT_ID,

    d.DEPARTMENT_NAME,

    (select count (*) from oehr_employees where department_id = d.department_id)

    "Number of employees", he said.

    substr (e.first_name, 1, 1) |'. ' || Select 'Name Manager',

    c.COUNTRY_NAME 'place '.

    OEHR_DEPARTMENTS d,

    E OEHR_EMPLOYEES

    OEHR_LOCATIONS l,

    C OEHR_COUNTRIES

    WHERE d.LOCATION_ID = l.LOCATION_ID

    AND l.COUNTRY_ID = c.COUNTRY_ID

    AND e.department_id = d.DEPARTMENT_ID

    AND d.manager_id = e.employee_id

    AND instr (superior (d.department_name), superior (nvl (:P2_REPORT_SEARCH,d.department_name))) > 0)

    I don't know exactly what is happening in the last line. I think I understand what the different functions but I'm not clear on the use of the: P2_REPORT_SEARCH string.

    What does this string? This code simply checking that d.department_name isn't NA?

    I have SQL experience but am not very familiar with the Oracle PL/SQL implementation. Can someone please give me a brief breakdown that check is doing in the context of the overall query? The application seems to work even if the conditional statement is not included.

    Thank you.

    2899145 wrote:

    Thanks for the reply. I apologize if the information I added was incomplete. The code came from the day 2 + Application Express (version 4.2) Developer Guide.

    In the section 'your own Application of 4 Buuilding' https://docs.oracle.com/cd/E37097_01/doc.42/e35122/build_app.htm#TDPAX04000 , they describe the creation of a report

    page that includes the "manager_id" and 'location_id '. The SQL query, I pasted above extracted from the data in other tables to substitute the real 'name of the Manager' and 'rent '.

    for the corresponding ID values. It makes sense, and the part of the SQL query that explicitly doing this makes sense.

    However, given that the document is a guide for the development of the APEX, I guess the command:

    AND instr (upper (d.department_name), upper (nvl (:P2_REPORT_SEARCH,d.department_name))) > 0

    done something valuable, and I do not recognize what is exactly the value.

    From a practical point of view why would I need to include this conditional statement?  Which only added to the application?

    Looking at the guide in question, it is clear that the

    AND instr(upper(d.department_name),upper(nvl(:P2_REPORT_SEARCH,d.department_name)))>0
    

    the line is completely unnecessary in the context of this tutorial, and it can be removed. The search in the tutorial app page is implemented by using a report filter interactive rather than a P2_REPORT_SEARCH element, which does not seem to exist at all. (It's a quirk of the APEX that bind variable references to non-existent items are replaced with NULL silently rather than exceptions). I thought that perhaps it would be legacy code a version of the tutorial prior to the introduction of interactive reports at the APEX 3.1, but I can't find explicit instructions to create such an element of filter in the 3.0 tutorial. I guess it must have been automatically generated by the application wizard when you create a standard report page.

    If you do not want to see the effect he would have (as described in the post above), leave it in the source report, add a text element of P2_REPORT_SEARCH, and a button "submit" on page 2 and experimenting to find different values of the element and clicking on the submit button...

  • Syntax of the case statement / WHEN

    The table I use a depreciation per fiscal year and the fiscal period.  I try to have the amount of depreciation to go to 2 different columns based on the fiscal year and the fiscal year.  I'm doing it with a nested case statement. I know that is not correct, because I get the message ORA-00905.  I'm relatively new to sql and it is contribtuing to my problem as well.  Here is the code I have and suggestions / corrections would be appreciated.  Thanks for the help...

    SELECT

    lao PDR. DEPTID as DEPTID,

    lao PDR. ASSET_ID as ASSET_NO,

    PA. Descr as DESCRIPTION,

    lao PDR. ACCOUNT_AD as AD_ACCT,

    PDL. DE_ACCT, to take into ACCOUNT

    lao PDR. ADEATH as AMT_DEPR,

    PDL. JOURNAL_ID as JRNL_ID,

    PDL. JOURNAL_DATE as JRNL_DT,

    lao PDR. FISCAL_YEAR as FY,

    lao PDR. ACCOUNTING_PERIOD AP,

    CASE

    WHEN RDP. FISCAL_YEAR = 2014 THEN

    WHEN RDP. PERIOD ACCOUNTANT = 11 THEN pdr. DEPR

    END AS CURR_MONTH,

    CASE

    WHEN RDP. FISCAL_YEAR <>2014

    WHEN RDP. ACCOUNTING PERIOD <>11 THEN pdr. DEPR

    END AS PRIOR_MONTH

    OF PS_DEPR_RPT pdr

    INNER JOIN PS_DIST_LN pdl

    THE pdl. BOOK = pdr. BOOK

    AND pdl. BUSINESS_UNIT = pdr. BUSINESS_UNIT

    AND pdl. FISCAL_YEAR = pdr. FISCAL_YEAR

    AND pdl. ACCOUNTING_PERIOD = pdr. ACCOUNTING_PERIOD

    AND pdl. ASSET_ID = pdr. ASSET_ID

    AND pdl. CF_SEQNO = pdr. CF_SEQNO

    INNER JOIN PS_ASSET PA

    WE pa. ASSET_ID = pdl. ASSET_ID

    AND pa. BUSINESS_UNIT = pdl. BUSINESS_UNIT

    WHERE

    lao PDR. BUSINESS_UNIT = "A0465.

    AND pdr. BOOK = 'RUN '.

    AND ((pdr. FISCAL_YEAR = 2014 AND pdr. ACCOUNTING_PERIOD = 11) OR (pdr. FISCAL_YEAR = 2014 AND pdr. ACCOUNTING_PERIOD = 10))

    Hello

    2713822 wrote:

    Thank you... I appreciate the information you provide when you answer these questions.  I always try to get the amount (from the same column) for 2 rows in different columns.  I tried the LAST_VALUE and LAG but it took a long time for the queries to run, I'm looking for another way to do the same.  I'm only using SQL to retrieve data.  I don't have the ability to create or insert.

    I looked the information above and the CASE statement to look like this:

    CASE

    WHEN RDP. FISCAL_YEAR = 2014

    AND pdr. ACCOUNTING_PERIOD = 11

    THEN the RDP. ADEATH AS CURR_MONTH

    ON THE OTHER

    lao PDR. ADEATH AS MONTHS PREVIOUS

    END

    But I'm now getting an "ORA-00905: lack of keyword" message.

    What I'm trying to do is to draw 2 lines 1 to 2014 / 11 and another for 2014 / 10.  The amount for the period 2014 / 11 should go in the current column and the amount for the period 2014 / 10 should go in the previous column.

    Before current assets management

    01 AB01 50.01 50.03

    ....

    If you want to give an alias for a column, then you can say "AS nome_alias" after that tell you what that is in this column.

    'AS nome_alias' applies to the entire column.  Cannot use 'alias_name' in the middle of an expression, for example, in the middle of a CASE expression, before the END keyword.

    If you want to have 2 separate output columns, curr_month and prior_month to your output, you must then 2 separate columns in your SELECT clause.  for example:

    SELECT pdr.branch

    pdr.asset

    CASE

    WHEN pdr.fiscal_year = 2014

    AND pdr.accounting_period = 11

    THEN pdr.depr

    END AS curr_month

    CASE

    WHEN...

    THEN...

    END AS prior_month

    PDR

    ;

    If post you some sample data (CREATE TABLE and INSERT statements), the results and explanations, I could show you how to complete the... sections.

    To find out what version of Oracle you have, use

    SELECT *.

    SINCE the release of v$.

    The output can be messy, like this:

    BANNER

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

    CON_ID

    ----------

    12 c Oracle database Release 12.1.0.1.0 - 64 bit Production

    0

    PL/SQL Release 12.1.0.1.0 - Production

    0

    CORE Production 12.1.0.1.0

    0

    AMT for 64-bit Windows: Version 12.1.0.1.0 - Production

    0

    NLSRTL Version 12.1.0.1.0 - Production

    0

    The important thing is the number 5 parts on the first line; 12.1.0.1.0 in the example above.

  • Find the sql query in statspack report

    Salvation;
    I have 11.5.10.2 and db version 9iR2... I took a statspack report, and I should find a sql query... But admin, is kill session and I can't see complite sorted SQL query by gets for DB...

    so the question is find this query which is kiiled by admin?

    Thank you

    Hello

    Its bad news to can not find this sql... So normally it istn killed by admin, I could find it from stats$ sql_summary or v$ sql_text?

    It is possible.

    Note: 153507.1 - Applications Oracle StatsPack
    https://metalink2.Oracle.com/MetaLink/PLSQL/ml2_documents.showDocument?p_database_id=not&P_ID=153507.1

    And another question... If I have a sql printing is eating my cpu or my server resource, how do I find this sql? Under what title I can find in the statspack report

    Refer to:

    Note: 232443.1 - how to identify the resource intensive SQL for Tuning
    https://metalink2.Oracle.com/MetaLink/PLSQL/ml2_documents.showDocument?p_database_id=not&P_ID=232443.1

    Kind regards
    Hussein

  • How can I show all the results returned by a sql query?

    Hi guys,.

    I need your help.
    Let's say I have a table: TableA. Fields in TableA are aleg, anon, monkeys. The following sentence can return, in general, several rows: select anon from TableA where aleg = somevalue. I would like to show the result of the anon column but no luck. If I try to display the results in a TextArea and the origin is a sql query shows that the first value of the line. I tried to see the like: display text (based in PLSQL) and a block anonymous plsql and coding
    DECLARE
    v_anon TableA.anon%TYPE;
    CURSOR v_cur IS
    Select anon from TableA where aleg = somevalue;
    BEGIN
    OPEN v_cur.
    LOOP
    SEEK v_cur INTO v_anon;
    EXIT WHEN v_cur % NOTFOUND;
    : FIELD_IN_FORM: = v_anon;
    END LOOP;
    CLOSE V_cur;
    END;
    but in this case, he showed no results.
    So the first question is what type of field can I use to show the result. And the second is what can I do to be able to show all the results returned by the query (if more than one line).

    concerning

    GMC

    We are all happy that you found a solution, but you must sign your messages and change your ID forum. It is always good to know the real name of the person you are communicating with. In addition, if you plan to get answer to your questions in the future, you must mark responses as useful or correct if they helped you solve your problems.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • SQL query as a filter in OBIEE

    I have a list of student_ID in a table (say A) and its subset in another table (table B)
    I want a filter so that only the student_ID in table A that are not in table B are selected.

    I'm selecting operator "not equal to / is not" of the student_id in table A and choose the option to SQL query to add value.

    Select distinct student_id from DatabaseName.B

    His does not work. His error after a large number of minor changes.

    Can you help how to solve this problem

    Try something like
    http://www.cool-bi.com/tweaks/JoinsinAnswers.php

    Use not exists or not instead of join.

    If brand aid

  • Case statement in the SQL Query prompt dashboard

    Hi Experts,

    I use the following case statement to generate default values in the prompt dashboard based on a condition (the other guest-generated values). Below are two of the query I've tried and the syntax error. I tried all the possibilities (like giving apostrophes, double quotes, don't quote not etc.), but could not understand the question. Don't know what exactly I'm missing here.

    Query 1:

    SELECT

    CASE

    WHEN @{PRType} = monthly THEN 'Participant pay '. "" Amount of PayRate "="15000"

    WHEN @{PRType} = daily THEN 'Participant pay '. "" Amount of PayRate "="650"

    WHEN @{PRType} = hourly THEN 'Participant pay '. "" Amount of PayRate "="1"

    ELSE ' 0'

    END

    OF 'PA-Participant pay. '

    Query 2:

    SELECT

    CASE

    WHEN @{PRType} = monthly THEN "15000"

    WHEN @{PRType} = daily THEN "650"

    @{PRType} = schedule THEN '1'

    ELSE ' 0'

    END

    OF 'PA-Participant pay. '

    This is the query that is generated in the log with error message file.

    1 log message:


    SELECT CASE WHEN Hourly = Monthly THEN "Participant Payroll"."Payrate Amount" = '15000' WHEN Hourly = Daily THEN "Participant Payroll"."Payrate Amount" = '650' WHEN Hourly = Hourly THEN "Participant Payroll"."Payrate Amount" = '1' ELSE '0' END FROM "PA-Participant Payroll"

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>=: Syntax error [nQSError: 26012]. (HY000)



    Comment 2:

    ;CASE WHEN To_Char (Hourly) = 'Hourly' THEN 1 ELSE 0 END 

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>(): syntax error [nQSError: 26012]. (HY000)

    Sorry, I wasn't clear... you must always put this CASE statement in a valid SQL SELECT statement.

    SELECT

    CASE

    When ' @{PRType}' = 'Monthly' THEN '15000'

    When ' @{PRType}' = 'Daily' THEN '650'

    ELSE '0' END

    OF 'PA-Participant pay. '

  • Help with making SQL query references to column aliases in the Case statement

    I need help with a sql query that I'm trying. I can go about it the wrong way, but I would be grateful if I could get any suggestions on possible solutions. This is my query:


    SELECT DISTINCT spriden_pidm, spriden_id id, spriden_last_name | ',' | spriden_first_name name,

    CASE
    WHEN rcresar_comm_code_01 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_01
    WHEN rcresar_comm_code_02 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_02
    WHEN rcresar_comm_code_03 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_03
    WHEN rcresar_comm_code_04 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_04
    WHEN rcresar_comm_code_05 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_05
    WHEN rcresar_comm_code_06 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_06
    WHEN rcresar_comm_code_07 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_07
    WHEN rcresar_comm_code_08 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_08
    WHEN rcresar_comm_code_09 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_09
    WHEN rcresar_comm_code_10 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_10
    END acg_elig_comm_code

    CASE
    WHEN acg_elig_comm_code = ' 268' THEN 'rigorous HS course. "
    WHEN acg_elig_comm_code = '269' THEN ' 2 or several AP or IB"
    WHEN acg_elig_comm_code = '270' THEN 'NOC as possible ".
    END comm_code_description

    OF spriden, rcresar, rcrapp1

    WHERE (rcresar_comm_code_01 IN ('268 ', '269', ' 270')

    OR rcresar_comm_code_02 ('268 ', '269', ' 270')

    OR rcresar_comm_code_03 ('268 ', '269', ' 270')

    OR rcresar_comm_code_04 ('268 ', '269', ' 270')

    OR rcresar_comm_code_05 ('268 ', '269', ' 270')

    OR rcresar_comm_code_06 ('268 ', '269', ' 270')

    OR rcresar_comm_code_07 ('268 ', '269', ' 270')

    OR rcresar_comm_code_08 ('268 ', '269', ' 270')

    OR rcresar_comm_code_09 ('268 ', '269', ' 270')

    OR rcresar_comm_code_10 ('268 ', '269', ' 270'))


    Rcresar_aidy_code = & aidy_code

    AND rcrapp1_aidy_code = rcresar_aidy_code

    AND rcrapp1_curr_rec_ind = 'Y '.

    AND rcrapp1_seq_no = rcresar_seq_no


    AND spriden_pidm = rcresar_pidm

    AND rcrapp1_pidm = rcresar_pidm


    AND spriden_change_ind IS NULL

    ORDER BY name


    The second case statement is where I don't know exactly what it takes to get what I want.

    Output should be like:
    spriden_pidm name ID acg_elig_comm_code comm_code_description
    «0000000000', ' 1111111111 ","John Doe","268", «rigorous HS race"»

    If I take the second case statement it works great except that I do not have my comm_code description column. My question is how can I use my first statement value box to determine this column? I think that I need a case statement as I have, but I don't know how to reference the value of acg_elig_comm_code. Any help would be greatly appreciated. Thank you.

    Published by: blackhole82 on January 20, 2009 09:20

    Hello

    You cannot use the alias column in the query, even where it is set (except in the ORDER BY clause).
    You can set the alias in a subquery and then use it in a great query, like this:

    WITH  sub_q  AS
    (
        SELECT DISTINCT spriden_pidm,spriden_id id, spriden_last_name||', '||spriden_first_name name,
            CASE
                WHEN rcresar_comm_code_01 IN ('268','269','270') THEN rcresar_comm_code_01
                WHEN rcresar_comm_code_02 IN ('268','269','270') THEN rcresar_comm_code_02
                WHEN rcresar_comm_code_03 IN ('268','269','270') THEN rcresar_comm_code_03
                WHEN rcresar_comm_code_04 IN ('268','269','270') THEN rcresar_comm_code_04
                WHEN rcresar_comm_code_05 IN ('268','269','270') THEN rcresar_comm_code_05
                WHEN rcresar_comm_code_06 IN ('268','269','270') THEN rcresar_comm_code_06
                WHEN rcresar_comm_code_07 IN ('268','269','270') THEN rcresar_comm_code_07
                WHEN rcresar_comm_code_08 IN ('268','269','270') THEN rcresar_comm_code_08
                WHEN rcresar_comm_code_09 IN ('268','269','270') THEN rcresar_comm_code_09
                WHEN rcresar_comm_code_10 IN ('268','269','270') THEN rcresar_comm_code_10
            END acg_elig_comm_code   -- Originally posted with , here (error)
        FROM spriden, rcresar, rcrapp1
        WHERE (rcresar_comm_code_01 IN ('268','269','270')
                OR rcresar_comm_code_02 IN ('268','269','270')
                OR rcresar_comm_code_03 IN ('268','269','270')
                OR rcresar_comm_code_04 IN ('268','269','270')
                OR rcresar_comm_code_05 IN ('268','269','270')
                OR rcresar_comm_code_06 IN ('268','269','270')
                OR rcresar_comm_code_07 IN ('268','269','270')
                OR rcresar_comm_code_08 IN ('268','269','270')
                OR rcresar_comm_code_09 IN ('268','269','270')
                OR rcresar_comm_code_10 IN ('268','269','270'))
        AND rcresar_aidy_code = &aidy_code
        AND rcrapp1_aidy_code = rcresar_aidy_code
        AND rcrapp1_curr_rec_ind = 'Y'
        AND rcrapp1_seq_no = rcresar_seq_no
        AND spriden_pidm = rcresar_pidm
        AND rcrapp1_pidm = rcresar_pidm
        AND spriden_change_ind IS NULL
    )
    SELECT    sub_q.*,
              CASE
                  WHEN acg_elig_comm_code = '268' THEN 'Rigorous HS course'
                  WHEN acg_elig_comm_code = '269' THEN '2 or more AP or IB'
                  WHEN acg_elig_comm_code = '270' THEN 'ACG possible'
              END comm_code_description
    FROM      sub_q
    ORDER BY  name
    

    Furthermore, you might think to rearrange your table, so that you do not have 10 columns (rcresar_comm_code_01, rcresar_comm_code_02,...) that essentially do the same thing. The usual way to handle this kind of one-to-many relationship is to have all rcresar_comm_codes in a separate table, one per line, with a pointer to the table where you have them now.

    Published by: Frank Kulash, January 20, 2009 11:35
    Syntax error has been corrected

Maybe you are looking for

  • Error: async story undefined reference?

    When I type in the search... it cuts my search and said... ReferenceError: asyncHistory is not defined. It has aged after the 1st 100 times. It happens on that computer. Here is a screenshot: http://i.imgur.com/9ObFUep.PNG

  • want to put maps itunes as a primary shopping card

    How to set the itunes card as the primary means of payment on my account

  • Can I use Win Xp setup application, found in the folder "I386"?

    It is possible, to reinstall win xp using the configuration file is located in the I386 folder on my hard drive, he asks a cab1 file, but I can't that assume it has only been extracted as a load of files with the last letter of their file name replac

  • Lost films...

    I imported a bunch of home movies on my mac.  I have not played them in awhile.  I tried tonight to see one and he was told that the file could not be found.  Where they might be?  I don't have another copy!

  • Unable to access any apps my photos. iPhone 6. iOS 9.1

    Hello. This has happened for a while. EverNote and Photoshop Fix 2 last applications are 3rd party cannot access my photos. Settings / Privacy / photos shows that no apps have requested access to my photos. Howard