Duplicate values are returned by using the case statement

Hello PL/SQL gurus and experts.

I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64-bit Production version

I am currently stuk with problem with the case values in double - displayign

Once I am using the following query (join of two tables)
select t.student_nm,
f.Test_RNK,f.Exam_rnk
from class_fact f,
method_dim   t
where t.method_key = f.class_key 
AND F.DE='H'
AND F.Date between '20120101' and '20120631'
It gives the student name and corresponding test and review

But if I use it as a query, then it displays a lot of values in double.
select t.student_nm,
(case when trim(upper(F.date)) between '20120101' and '20120631' and trim(upper(F.DE)) = 'H' then
                   F.Exam_RNK
                  else
                   0
                end
                ) yrrk
 from class_fact f,
method_dim   t
where t.method_key = f.class_key 
I can do stupid mistake but kindly suggest me.

Thank you

Why you have removed the bottom two filters in the second query?

AND F.DE='H'
AND F.Date between '20120101' and '20120631'

CASE filter your data. USED in your SELECTION list will be only to manipulate these data for the particular column.
You must keep your filter because it is, if you expect the reords even to return

Your request must therefore

select t.student_nm,
(case when trim(upper(F.date)) between '20120101' and '20120631' and trim(upper(F.DE)) = 'H' then
                   F.Exam_RNK
                  else
                   0
                end
                ) yrrk
 from class_fact f,
method_dim   t
where t.method_key = f.class_key
AND F.DE='H'
AND F.Date between '20120101' and '20120631'

Published by: JAC on October 12, 2012 19:08
1. is it a running query? You use DATE as column name?
2. why you store data to date as strings?

Tags: Database

Similar Questions

  • using the case statement


    Hello

    How can I convert a code for the below sql case statement:

    If)

    (length of (tmp_co_orig_val) < = 0 OR tmp_co_orig_val < = 0 OR tmp_co_orig_val == 1 OR tmp_co_orig_val > = 9999999)

    OR

    ((tmp_co_orig_val == 999999 AND (length of (tmp_rcr_orgn_ltv_rt) < = 0 OR tmp_rcr_orgn_ltv_rt < tmp_rcr_orgn_ltv_rt > 1.3 GOLD 0.15)))

    Start

    tmp_collatvalue = «»

    tmp_msg_cd = 115

    end

    Is the case statement below that I wrote is correct. I don't have an environment now to test.  Please advice.

    BOX WHEN (CHAR_LENGTH (tmp_co_orig_val) < = 0 OR tmp_co_orig_val < 0 OR tmp_co_orig_val = 1 OR tmp_co_orig_val = > = 9999999)

    OR (tmp_co_orig_val = 999999 AND (CHAR_LENGTH (tmp_rcr_orgn_ltv_rt) < = 0 OR tmp_rcr_orgn_ltv_rt < tmp_rcr_orgn_ltv_rt > 1.3 GOLD 0.15))

    THEN tmp_collatvalue IS NULL AND tmp_msg_cd = 115

    END

    Hello

    937454 wrote:

    Thanks Frank. Really helps. But I have to write a sql statement

    But can you also specify, if I made a mistake in my code, or it's ok.

    There are no CASES reported in Oracle SQL.

    Oracle SQL has BOX expressions, but they only return a single value.  You cannot set 2 columns in the same expression BOX.

    Perhaps the best thing to do in pure SQL for you is to write a CASE expression, very similar to the CASE statement above, in a subquery and use the results of this in 2 separate expressions of BOX (very simple) in a Super application.

  • Tuning - using the CASE statement in the WHERE clause of the query

    Hi all

    My request has been changed to use a CASE statement in the WHERE clause to examine the data to some columns based on a parameter value. This modified request is made a full table and constantly running scan. Please suggest what can be done to improve its performance:

    Query:
    SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date,
    os.acctnum,
    os.avieworigin_refid,
    COUNT(1) cnt_articleview,
    SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm
    FROM TABLE1 os
    WHERE os.acctnum IS NOT NULL
    AND os.avieworigin_refid IS NOT NULL
    AND os.requestdatetime IS NOT NULL
    AND UPPER(os.success_ind) = 'S'
    
    AND CASE WHEN
    Param_ValueToCheck  = 'FULL' AND get_date_timestamp(os.requestdatetime)  BETWEEN 
    TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    WHEN
    Param_ValueToCheck  = 'INCR' AND os.entry_createddate  BETWEEN 
    TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    END = 1
    AND CASE WHEN
    Param_ValueToCheck  = 'FULL' AND os.entry_CreatedDate BETWEEN 
    TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    WHEN
    Param_ValueToCheck  = 'INCR' THEN 1
    END = 1
    GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;
    Description of the table:
    (Number of lines: approx. > amount 600 000 000)
    Name                           Null     Type       
    ------------------------------ -------- ------------
    ARTICLEID                      NOT NULL NUMBER(20) 
    USERKEY                                 NUMBER(10) 
    AVIEWORIGIN_REFID                       VARCHAR2(10)
    SUCCESS_IND                             VARCHAR2(2)
    ENTRY_CREATEDDATE                       DATE       
    CREATED_BY                              VARCHAR2(10)
    FILENUMBER                              NUMBER(10) 
    LINENUMBER                              NUMBER(10) 
    ACCTNUM                                 VARCHAR2(10)
    AUTOCOMPLETEDTERM                       NUMBER(2)  
    REQUESTDATETIME                         VARCHAR2(19)
    Explain Plan
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 2224314832
    
    ----------------------------------------------------------------------------------------------------------
    | Id  | Operation            | Name              | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    ----------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |                   |   590 | 33040 |  2501K  (1)| 08:20:15 |       |       |
    |   1 |  HASH GROUP BY       |                   |   590 | 33040 |  2501K  (1)| 08:20:15 |       |       |
    |   2 |   PARTITION RANGE ALL|                   |   590 | 33040 |  2501K  (1)| 08:20:15 |     1 |1048575|
    |*  3 |    TABLE ACCESS FULL | TABLE1 |   590 | 33040 |  2501K  (1)| 08:20:15 |     1 |1048575|
    ----------------------------------------------------------------------------------------------------------
    
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(UPPER("OS"."SUCCESS_IND")='S' AND CASE  WHEN ('FULL'='FULL' AND
                  "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN
                  'FULL'='INCR' THEN 1 END =1 AND "OS"."REQUESTDATETIME" IS NOT NULL AND CASE  WHEN ('FULL'='FULL'
                  AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN ('FULL'='INCR' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE('
                  2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE('
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                  2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 END =1 AND "OS"."ACCTNUM" IS NOT NULL AND
                  "OS"."AVIEWORIGIN_REFID" IS NOT NULL)
    Published by: Chaitanya on June 9, 2011 02:44

    Published by: Chaitanya on June 9, 2011 02:47

    When it is executed individually, MERGE LOGIC 1 and LOGIC of MERGE 2 take about ten for a daterange of 30 days data.

    BUT FULL is to get the scores of APR - JUN, INCR becomes partitions for MAY so not both 30 days.
    Are compare us like with like?

  • Schema export multile using the case statement

    Hello

    I want several export schema using case statement.

    provable I 4 schema test1, test2, test3 test4 for the scheme I created scripts for each of them either 4 scripts but I want only a scripts instead of 4 scripts. Please suggest how to write shell scripts using a case statement (via a parameter name or the schema).

    example of diagram of TEST1.

    expdp "" system/redhat as sysdba' "dumpfile directory = TEST1.dmp = DUMP_DIR = TEST1.log patterns = TEST1 logfile logfile = TEST1_Export.log

    is it possible if you use under case statement (via the name of parameter/schema)

    as case 1: TEST1
    2: TEST2
    3: TEST3
    4: TEST4

    If I pass the value as TEST1, and TEST1 schema export is made.

    No, it's easier.
    In addition, you can only get the number and then use TEST$ {export_schema} instead.
    But in any case you don't have no need 'breaks '.

  • 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

  • Help: How to use the Case statement in the ODI11g Interface?

    Hello
    My basic source I get 'Year' values and I want that these values result code in the interface and after translation want to push on the target system.
    Example:
    Database source, I get value for
    Year
    2010
    2011
    2012

    When I get the year 2010 I want to change the value in "FY10".
    When I get year 2011 I want to change the value in "FY11.
    and even for the year 2012 to "FY12.
    I've tried to make the Case statement, but had no success.
    I don't want to create the lookup table in the source system.
    Any help in this matter.

    Thank you

    Concerning
    Sher

    Published by: Sher Ullah Baig on August 26, 2012 17:52

    CASE
    WHEN source_column = '2010' THEN 'FY10.
    WHEN source_column = '2011' and THEN 'FY11.
    WHEN source_column = '2012' and THEN 'FY12.
    END

  • Using the Case statement in Where clause with operator

    Hi all

    I'm doing the following work (this is just a simple version of what I'll eventually need):

    Sorry, I forgot how to use the code tags...

    and li. MAJOR_ACCT in case
    When: prompt = 'Energy' then ('9320906 ', ' 9321471')
    end


    Problem is that I get a missing closing parenthesis error.

    Wouldn't - that evaluate against a value(as below) it works fine:

    and li. MAJOR_ACCT in case
    When: prompt = 'Energy' then ('9320906')
    end


    Any thoughts? Is it possible to use a box (or decode) in an In clause with multiple values? I tried to use decode as well and get the same results.

    Thank you.

    Darren.

    What:

    and ( case
            when :prompt = 'Energy' and li.MAJOR_ACCT in ('9320906', '9321471') then 1
            when :prompt = 'Vehicle' and li.MAJOR_ACCT in ('9812180', '9812320')  then 1
            when :prompt = 'Meals' and li.MAJOR_ACCT in ('983120', '983452') then 1
          end
        ) = 1
    
  • using a Case statement to display the values of column even as table headers

    I have a database that has been set up kind of tricky, in that some tables are made up of columns that are field names and one link to another table that contain the data for these field... also names there ID displays as many lines instead of as a row of data. I would like to write a query to extract that information and display it as one line for each ID.

    example: table 1

    ID, name, itemresponse and itemcode, Description

    Dee Jones Childrens Hospital 123 SITE location

    123 dee Jones, Date of appointment next NEXTAPPT 22/04/2014

    123 dee Jones was on bedrest NOSHOW reason do not show

    I would like to have the display of data as a record on this same patient, instead of as 3 separate registers (with the Description column in table 1

    Table 2

    ID, name, place, Date of the next meeting, show no reason

    123 dee Jones Childrens Hospital 22/04/2014 was the bed rest

    I have included the code I worked on below my question, for me to get the desired results should I use the Case statement and it's the right way to do it below?

    (SELECT
    PAT.ID "PATIENT ID."
    PAT. FIRST | » '|| PAT. "PATIENT FIRST NAME."
    PAT. "PATIENT DOB," DATE_OF_BIRTH
    DS. Date 'Date of inpatients ',.
    Dai. ITEM_CODE "Item Code",
    Dai. DESCRIPTION "Description."
    Siad. ITEM_RESPONSE,

    Max (CASE WHEN dai. ITEM_CODE IS "SITE" THEN DAI. Decription
    ANOTHER NULL
    END) AS "name of the hospital."

    Max (CASE WHEN DAI.) ITEM_CODE IS 'NEXTAPPT' THEN DAI. ITEM_Description
    ANOTHER NULL
    END) AS 'next Appt Date. "

    Max (CASE WHEN DAI.) ITEM_CODE IS "LASTDATE" THEN DAI. Description
    ANOTHER NULL
    END) AS 'last visit Date.

    Max (CASE WHEN DAI.) ITEM_CODE IS 'NOSHOW' THEN DAI. Description
    ANOTHER NULL
    END) THAT "the reason has not shown".

    Of
    (PAT.ID "IDENTIFYING PATIENT",
    PAT. FIRST | » '|| PAT. "PATIENT FIRST NAME."
    PAT. "PATIENT DOB," DATE_OF_BIRTH
    DS. Date 'Date of inpatients ',.
    Dai. ITEM_CODE "Item Code",
    Dai. DESCRIPTION "Description."
    Siad. ITEM_RESPONSE

    Of

    dm_sessions Ds,
    dm_session_assessments dsa,
    DAS dm_admin_sections,
    dm_session_assessment_items Siad,
    Dai dm_admin_items,
    Po Patient_Orders,
    Inventory inv,
    Patients_Table PAT
    dm_admin_categories CAD

    where dsa.session_Id = ds.session_Id
    and PAT.ID = ds. Patient_ID
    and dsa.excluded_assessment =' no
    and dac.category_code = 'OPEN'

    and dsa.section_id = das.section_id
    and das.category_id = dac.category_id
    and das.section_code = 'northwest'
    and dai.section_id = das.section_id
    and dsai.item_id = dai.item_id
    and dsai.session_assessment_Id = dsa.session_assessment_Id
    and dsai.excluded =' no
    - and Dai.ITEM_ID = Dsai.ITEM_ID
    and Dai.ITEM_CODE IN ('SITE', 'NEXTAPPT', 'LASTDATE', 'NOSHOW')
    and po.patient_ID = ds.patient_ID
    and in. NDC_NO = inv. NDC_NO
    and inv. TDRUG_ABBREV = in. DRUG_ABBREV

    PAT.ID GROUP, PAT. FIRST | » '|| PAT. LAST, PAT. DATE_OF_BIRTH, ds. Date, dai. ITEM_CODE, dai. DESCRIPTION, Siad. ITEM_RESPONSE))

    Hello

    DATE is not a very good name for a column.  Use something like EVENT_DATE, that will not be confused with a keyword from Oracle, instead.

    I don't see something like this column in the CREATE TABLE statement.  He will always be the same value on all lines?

    Here's a way to get the results you requested:

    SELECT id

    first name | ' ' || LastName AS name

    Date of birth

    MAX (CASE WHEN item_code = "NEXTAPPT", THEN item_response END) AS next_appointment,

    MAX (CASE WHEN item_code = "LASTDATE" THEN item_response END) AS last_visit_date,

    MAX (CASE WHEN item_code = "SITE" THEN item_response END) AS location

    FROM mytable1

    GROUP BY id, firstname, lastname, dob

    ;

    Of course, I can't test it very well until you post INSERT statements for the sample data.

    I guess that 2 or more lines of the entry have the same id, then they will necessarily be first name last name, the name and date of birth, too.  No doubt they are standardized in your actual tables.

  • TDE is not "transparent" to the CASE statement

    Hello

    I have installed oracle (10) database with TDE. It works very well with almost all queries. But I have problems when I try to use the CASE statement.


    He comes to the table, I created:

    {color: #0000ff} create table t_test)
    col1 varchar (128)); {color}

    This query returns an empty result (as planned, because there is still no data in the table).

    {color: #0000ff} to select)
    When col1 = 'test' then 'test '.
    end) as Carter
    of t_test
    {color}
    I now encrypt the column with the following statement:

    {color: #0000ff} change alter table t_test (col1 encrypt using "AES256" without salt); {color}

    And try again the same statement:

    {color: #0000ff} to select)
    When col1 = 'test' then 'test '.
    end) as Carter
    of t_test
    {color}
    He now returns {color: #ff0000} ORA-00932 inconsistent data types: expected BINARY got {color} CHAR

    But if I try:

    {color: #0000ff} select *.
    of t_test
    {color}
    There is no errors (returns empty result, as expected).

    I tried even with data, with the same result.

    Could someone please tell me what I'm doing wrong here?

    Thank you.

    You touch the Bug 6262107 'ORA-932 of the CASE expression sought with encrypted column:

    Description:
    "ORA-932 incompatible data types: expected BINARY got TANK ' is triggered.
    on a query with a case expression sought on a column with TDE.

    for example:
    CREATE TABLE TDE_TEST (COL1 VARCHAR2 (1));
    INSERT INTO TDE_TEST VALUES('1');
    ALTER TABLE TDE_TEST CHANGE (COL1 ENCRYPT WITHOUT SALT);
    SELECT CASE WHEN COL1 = '1', THEN 'A' OF ANOTHER END 'B' OF TDE_TEST;
    ^
    ORA-00932: inconsistent data types: expected BINARY got TANK

    Workaround solution:
    Convert a simple case of the searched case expression expression.

    So, I updated the sql works:
    SQL > select (case col1
    2 when 'test' then 'test '.
    3 end) as Carter
    4 * of t_test
    /
    no selected line

    I hope this helps.

  • When I burn CD for my use on the computer, sometimes the order of the songs are returned, starting with the last song first.

    * Original title: Windows Media player

    When I burn CD for my use on the computer, sometimes the order of the songs are returned, starting with the last song first.  This is the CD, or I do something wrong?  This isn't an ongoing problem... most of the time it's ok.  Can I change the order manually. If Yes, where and how.

    Thank you

    Lee

    Lee - there are a number of possibilities. First of all, it depends whether you burn audio disks or data - if they are audio discs, you can check and rearrange the order of songs in the burn list - if necessary - before you start burning. If you drag multiple files to the burn list quite often the last track you clicked on will go upward, so I wonder if it is what can happen. Back with a little more detail if I not quite correctly interpreted the problem. Best regards, Ric.

  • Siebel field values are not passed to the OPA: error on WD Smoke Test

    Hello

    I installed OPA siebel connector locally and deployed determination determination of web and server to tomcat server. The 'DS smoke Test' button works well, but the 'WD Smoke Test' does not work correctly. After the installation by clicking on the button opens a pop-up window with "page cannot be displayed".

    I changed the symbolic for 'Employee' as URL:

    http://localhost: 8085/siebel-web-determinations/startsession/AdminSmokeTest

    (from the original one: http://localhost:8085 / siebel-web-determinations/startsession/AdminSmokeTest/en-US? user = [UserID] & caseID =, [UserID], [ObjectID], AdminSmokeTest)

    This show opens the popup window and and it asks the question ' what is the text of valid user?' by clicking on it application "which is a Siebel Admin user's first name?" then the subsequesnt questions and after the last questions it shows if it is valid Siebel Admin record ot not. If the rule works correctly.

    Now my questions are:
    1. how the Siebel field values will be passed to the determination of the Web? Ideally result response (if that's a record valid sadmin) should have been displayed in the window pop up directly by clicking on the button 'WD Smoke Test' with the employee field values passed, instead he asks for input.

    2. the field mappings are definde in the automation of the Admin-Policy-> show mappings. The field values are passed correctly to the server of determination, but how to pass for determination of the Web? The same mapping works for the determination of the Web as well?

    3. If I use the old url for employee (http://localhost: 8085/siebel-web-determinations/startsession/AdminSmokeTest/en-us? user = [username] & caseID =, [UserID], [ObjectID], AdminSmokeTest) the user id is passed correctly but it is throwing an error.

    4. in the Administration - policy Automation-> Web determinations it gives the following error.

    [An error occurred when loading the case ID "8SIA-82CJP, SADMIN, AdminSmokeTest".
    This error has been recorded and is available in the application logs.

    Support and assistance please contact [email protected]].

    If I change the url as before, then he asks the same questions. What is this point of view?

    Thanks in advance!

    Kind regards
    ALIOU

    ALIOU,

    One of the key things to note about the OPA Web determinations for Siebel is which is needs component EAI run on the Siebel server for it to work. There is an article on this in the installation guide where there you preform a test to verify that EAI_ANON_ENU is running on the Siebel server (located on pages 12-13 on the installation guide).

    1. for determinations of Web works properly, you must leave the URL token exactly as indicated in the installation guide. In addition, determinations Web use EAI (mentioned above) to pass information to the Web of Siebel determinations.

    2. same as number 1.

    3. again once it goes back to check that the EAI runs.

    4. make sure that the user you are logged in as has the responsibility to use this point of view.

    In addition to all this... once EAI works you need to check the incoming Web Service URL and point them to the location of the IAE but also change the path to the IAE in the file data-siebe - adapt .properties. Also, be sure to match the user name and password in this file for what you use to connect to Siebel with.

    -Adam Starr

  • Return by using the function number

    How can I return number using the function.

    Here is my procedure but do not in the name of variable or setting up as a variable...

    create or replace function Calculate_number)
    Number 1 in number,
    Number2 number)
    Return number is
    Start
    declare
    number of result;

    Select number1 + number2 as a result of double;


    Return (result);
    end;

    Hello

    You have not need double a lot in PL/SQL.

    CREATE OR REPLACE FUNCTION Calculate_number
    (
         number1 IN NUMBER,
         number2 IN NUMBER
    )
    RETURN NUMBER
    DETERMINISTIC
    IS
           result number;
    BEGIN
         result := number1 + number2;
    
         RETURN Result;
    END      Calculate_number;
    

    Strored procedures, local variables are declared between statements IS and BEGIN. DECLARE in a stored procedure starts a nested block to BEGIN, with its own local variables, which is rarely necessary. (Nested BEGIN blocks are not so rare, but they almost never have local variables need a nested block. Most people here all variables of the function complete together before the first START.)

    If the function always returns the same value when it is called with the same arguments, then Deniz it as DETERMINISTIC; It might make it faster to use.

    There are many good reasons to use a variable as results, but if you don't happen to have one, then you can do this:

    CREATE OR REPLACE FUNCTION Calculate_number
    (
         number1 IN NUMBER,
         number2 IN NUMBER
    )
    RETURN NUMBER
    DETERMINISTIC
    IS
    BEGIN
         RETURN  number1 + number2;
    END      Calculate_number;
    

    Published by: Frank Kulash, October 22, 2010 12:37
    Fault corrected typo (thanks, HM); Added after the remarks.

    Published by: Frank Kulash, October 22, 2010 13:28

  • How to use the case and decode to extract data

    Hello gurus of PL/SQL,.

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64-bit Production version

    I have a table in the following form-
    drop table TT2;
    create table TT2(College, Class,gender,status,fees) as select
    'IITB','MBA','M','P',255600 from dual union all select
    'IITK','MTech','M','P',300000 from dual union all select
    'IITD','MBA','F','P',450000 from dual union all select
    'IITKH','MBA','F','P',350000 from dual union all select
    'IITC','MTech','F','P',420000 from dual union all select
    'IITB','MTech','M','P',185000 from dual union all select
    'IITC','MTech','M','P',235000 from dual union all select
    'IITD','MBA','F','F',175000 from dual union all select
    'IITM','MBA','M','F',257000 from dual union all select     
    'IITKH','MTech','F','P',335000 from dual union all select
    'IITD','MBA','F','P',540335 from dual union all select
    'IITC','MBA','F','F',125089 from dual union all select
    'IITD','MTech','M','P',290756 from dual union all select
    'IITM','MBA','M','P',200000 from dual union all select     
    'IITKH','MBA','F','F',534990 from dual union all select
    'IITD','MBA','F','P',221000 from dual ;
    certain conditions of extraction are as follows-

    MATTER OF STATE
    College of 'IITB' and status = 'P'-'good WestRegion '.
    College of 'IITC' and status = 'P'-'good SouthRegion '.
    College 'IITD' and 'IITK' and status = 'P' and type = 'F' - 'female NothRegion spent.
    College not in 'IITK' and status = 'F' - 'Ex Kanpur Failed'

    Results-
    Region Statnding     Fees
    WestRegion Passed     440460
    SouthRegion Passed     655000
    NothRegion Female Passed     1386335
    Ex Kanpur Failed     1092079
    Used SQL
    I use the following query that only make sure of the case, but it's not how I want to exit, if I try to use the case to breast to decode then how to work on it.
    SELECT (CASE WHEN College in ('IITB') and status='P' then sum(fees) else 0 end) WP,
    (case when College in ('IITC') and status='P' then sum(fees) else 0 end) SP,
    (case when College in ('IITD','IITK') and gender='F' and status='P' then sum(fees) else 0 end) NFP,
    (case when College in ('IITK') and status='F' then sum(fees) else 0 end) ExKF
    FROM 
    TT2
    GROUP BY College, Class,gender,status
    SELECT CASE WHEN College in ('IITB') and status='P'
                        then 'WestRegion Passed'
                when College in ('IITC') and status='P'
                        then 'SouthRegion Passed'
                when College in ('IITD','IITK') and gender='F' and status='P'
                        then 'NothRegion Female Passed'
                when College in ('IITK') and status='F'
                        then 'Ex Kanpur Failed'
                else 'Others' end region_standing,
                sum(fees) fees
    FROM TT2
    GROUP BY  CASE WHEN College in ('IITB') and status='P'
                        then 'WestRegion Passed'
                when College in ('IITC') and status='P'
                        then 'SouthRegion Passed'
                when College in ('IITD','IITK') and gender='F' and status='P'
                        then 'NothRegion Female Passed'
                when College in ('IITK') and status='F'
                        then 'Ex Kanpur Failed'
                else 'Others' end;
    
  • You are able to use the CD of Windows Vista operating system on a laptop that has Windows 7 Home on it to use the Interface of Windows Vista?

    My situation is that I have a laptop that is a Windows 7 machine. I have a need where I'm considering purchasing a CD of Windows Vista operating system. It comes to be able to use the Interface of Windows Vista? I have a technical support of experience under my belt and I remember that if you need to have a different operating system available that you can use this operating system without installing it on your system.

    I really could use a version of Windows Vista now my educational purposes. My current computer has Windows 7 home running on it right now. Could you or someone give me Options to work with. I'll look forward to your response.

    Thank you

    Gary

    Q: "you are able to use the Windows Vista OS CD on a laptop that has Windows 7 Home above to use the Interface of Windows Vista?"

    A.  No.

  • Hello, we have a company agreement and we are entittled to use the master collection package. Based on thi

    Hello

    We have business agreement and we are entittled to use the master collection package. Based on this, we want to upgrade Flash builder 4.7. Please let us know how can we do it and how to get the keys.

    -Med

    @Anamika018: please contact Adobe volume licensing representative technical support to access Fb 4.7 under a volume license business - they'll be able to give the right for the product.

Maybe you are looking for

  • At all times by clicking on the browser and the

    Whenever I try to watch a video of YouTube, the browser keeps acting like im clicking off of it and clicking on it again. It keept repeating that until I closed the tab, then returned to normal.

  • What exactly does the "recovery disk"?

    I'm about to reinstall everything on my laptop but would like to know what exactly is the "recovery disk"... I presume that it formats the HARD drive with a clean installation of the operating system and all applications toshiba as a CD burner, VAP e

  • Satellite A50-108: how to remove the CD/DVD drive?

    I want to update my CD - RW drive for a dvd burner, but can't get the old drive of the laptop.I removed the screw on the underside of the laptop, but it won't come out. Do we know if there is any other screws received a way to remove the drive of any

  • I want to comment on an idea for a new feature in Windows.

    original title: 'click green '. Dear Microsoft, I thought of an idea today what I call 'green click '.  It is a system of click energy rating on the browser.  When the cursor passes over a link, it turns green, for example, or orange.  When the curso

  • Printer cannot communicate since the upgrade to windows 7

    My Lexmark x 4650 is unable to communicate since the upgrade from vista to Windows 7.  He asks me to authorize the communication of bidrectional, once I do this for a reason that it won't save any