Use to decode

Hello world

I put a code inside my report 6i SQL query statement, but I want only the decoding to bring value that is greater than the other. The only way I know how to use it is if a value is null then bring value, but not when a value is greater than the other.

Can someone help me please?

This is the code:

SELECT B.PERIOD,B.GRADE,B.CLASS_ID,A.CLASS_NAME,
CREDIT_VALUE_FIN,DECODE(ROUND(B.FINAL_GRADE), NULL, B.SEMESTER_REC2, ROUND(B.FINAL_GRADE)) AS FINAL_GRADE,B.GRADE_LETTER,NOTAS,SEMESTRES,C.LAST_NAME,
C.FIRST_NAME,C.GENDER
FROM TABLE_1 A, TABLE_2 B,TABLE_3 C
WHERE B.SCHOOL_ID = :CIA AND
               B.STUDENT_ID = :ESTUDIANTE AND
               B.GRADE IN ('9','10','11','12') AND
               B.FINAL_GRADE IS NOT NULL AND
               B.SCHOOL_ID = A.SCHOOL_ID AND
               B.CLASS_ID = A.CLASS_ID AND
               B.PERIOD = A.SCHOOL_YEAR AND
               B.TEACHER_ID = A.TEACHER_ID AND
               C.SCHOOL_ID = B.SCHOOL_ID AND
               C.STUDENT_ID = B.STUDENT_ID
               ORDER BY B.CLASS_ID

I'm not 100% sure what you're asking.  It is more a question of SQL that you would be better to post in this forum (PL/SQL, and SQL), but...

You say you want to compare B.FINAL_GRADE to B.SEMESTER_REC2 and then select the value of the people?  If so, you can use DECODE with the digital SIGN function.  Something like this:

..., Select decode (sign (round (b.final_grade) - b.semester_rec2), 1, round (b.final_grade), b.semester_rec2) final_grade,...

Tags: Oracle Development

Similar Questions

  • Software used to decode the media not available on this system

    I read a lot on this subject on various sites of forms and failed to find a solution.

    My project is filmed in 1080i @22Mbps and is 2 hours long that I split on two discs... There is NO images or graphics aside a grab single image to roll over the titles, there is some .mp3 and one. WMA file for audio.

    My method of editing, I edited the entire project in a single calendar, so when I get overall even length I it spread over approximately a two-disc length... Disc 2 was made as H.264 blu - ray and any in yet for blu - ray authoring this worked flawlessly, however with disc one I get the error "the software used to decode the media not available on this system...". blah blah blah! »

    I'm working on windows 10 PC with enough RAM and processing power and graphics.

    Can anyone provide a reason or a solution please.

    I rechecked the timeline and there are no gaps or breaks in there, I made the file as H.264 and imported the .mp4 still work but flow is low.

    Thank you

    P.

    Ok.. then MPEG2-Blu-ray has imported and burned to disc correctly... I'll let discs go to the client in this format and hope that its ok for them

  • What approach would be best for creating a condition of display by using the DECODE function criteria?

    Hello world

    The requirement is to filter a LOV based on a date entered by the user and a condition that uses DECODE. If : update or : pSystemLinkageFunctionDate Exchange then the LOV should be updated. So, I created a VO of read-only by using SQL. But I can't create a view of criteria that uses the DECODING. What approach would be the best method to meet this requirement?

    Select

    PET.expenditure_type

    pet.start_date_active

    pet.end_date_active

    petsl.start_date_active

    petsl.end_date_active

    petsl.system_linkage_function

    Of

    pa_lookups pl

    pa_expend_typ_sys_links petsl

    pa_expenditure_types pet

    pa_system_linkages psl

    where 1 = 1

    and pet.unit_of_measure = pl.lookup_code

    and pet.expenditure_type = petsl.expenditure_type

    and petsl.system_linkage_function = psl.function

    and pl.lookup_type = 'UNIT '.

    and: pDate between nvl(pet.start_date_active,:pDate)

    and nvl(pet.end_date_active,:pDate)

    and: pDate between nvl(petsl.start_date_active,:pDate)

    and nvl(petsl.end_date_active,:pDate)

    and petsl.system_linkage_function = decode(:pSystemLinkageFunction,'L','S','E')

    James

    Hi Timo,

    ADF business components: 11.1.1.62.29

    Platform Java (TM): 1.6.0_24

    Oracle IDE: 11.1.1.6.38.62.29

    Support for version control: 11.1.1.6.38.62.29

    Thanks for the link... I'll take a look. However, the DECODING work now; I wasn't quite deep in the stack trace to find the error that turned out be related to one of the dregs.

    James

  • Adobe still the software that is used to decode the media is not available on this system. install the correct decoders for the file you are editing can help fix the problem

    Hello

    I got this message after the import on ten H.264 files that I coded for Adobe media encoder.  "It is not available on this system from adobe yet the software that is used to decode the media. install the correct decoders for the file you are editing can help fix the problem. »

    The files that we have shot with HD cameras.  Edited in Premiere Pro CS3.  I installed the update 3.0.1 with always the same error.

    I also tried a new project and after about ten or so files imported into a timeline, the breakdown of the system.  I tried twice...

    Thanks in advance

    Please report to us. I don't know the exact specifications. for stills in still, the limit is 4000 pixels in the largest dimension for PrPro.

    Now, I must add that in PS. resizing algorithms are better, in my opinion, than those of PrPro and again. This means that there is nothing to gain and quality of untying, important images much larger than the size of the frame of the project, i.e. of 720 x 480 for NTSC SD projects yet. The size of the image will be the limiting factor, so scratch that.

    Even in projects PrPro, I resize to exactly what I need. If I will not pan on a zoomed image, I resize it to the size of the image of the project. If I move on a zoomed image, I resize just what I need.

    Good luck

    Hunt

  • Problem using the DECODE function

    I'm trying to decode what follows, but I seem to have a problem of syntax:
    decode
    (
           p.balls,p.strikes,
           1,0 '1-0 Count',
           2,0 '2-0 Count',
           3,0 '3-0 Count',
           0,1 '0-1 Count',
           0,2 '0-2 Count',
           1,1 '1-1 Count',
           2,1 '2-1 Count',
           3,1 '3-1 Count',
           0,2 '0-2 Count',
           1,2 '1-2 Count',
           2,2 '2-2 Count',
    ) as Count,
    what I'm trying to take place is whenever the column of balls a '1' and the column to strike a '0' to decode the number of 1 - 0"etc...

    Hello

    Why use DECODE at all?

    TO_CHAR (p.balls) || ' -' || TO_CHAR (p.strikes) || ' Count'
    

    Assuming that you really need to use DECODE: it only works on a single value.

    You can combine your two values into one:

    DECODE ( (10 * p.balls) + p.strikes
           ,  0, '0-0 Count'
           ,  1, '0-1 Count'
           ,  2, '0-2 Count'
           ,  3, '0-3 Count'
           , 10, '1-0 Count'
    ...
           , 32, '3-2 Count'
           )
    

    or DECODE the two columns separately.

    DECODE ( p.balls
           , 0 '0-'
           , 1 '1-'
           , 2 '2-'
           , 3 '3-'
           )
    ||
    DECODE ( p.strikes
           , 0 '0 Count'
           , 1 '1 Count'
           , 2 '2 Count'
           )
    
  • Using an ATI TV Wonder HD 750 PCIe and the Media Center can't find the analog signals of the conductor not to use a decoder

    I just installed a diamond ATI TV Wonder HD 750 PCIe on my 64 bit Windows 7 system (it's actually the second tuner card I tried) and still get the same problem. Media Center recognizes the card and both tuners analog and digital, but fails the analogue listening. I get digital very well. I tried to add a channel manually and still no luck. I use cable TV with no cable box and tested the signal on my TV and receive all channels.

    I also downloaded the latest Diamond driver and installed all updates more recent windows.

    In Media Center, I tried to automaticlly and manually select my signal and each combination, but available with no luck.

    Can you please help

    Rob


    Because, for an analog tuner, Media Center requires that said tuner is an MPEG2 Encoder (or that the manufacturer creates a software encoder which emulates this.)  The Theater HD 750 chip is not this, and it seems (after some looking) that ATI has not created a software encoder (side note: they are unlikely to do so, because they left the tuner market.)

    Out of curiosity, what was the 'other tuner"which has been tried before?

    Honestly, my recommendation would be to return the tuner (if possible) and get a combo tuner or hybrid that is known to work properly.  My first recommendation would be for a Hauppauge HVR-2250 (Council dual combo/hybrid), because it works wonderfully in MC as a tuner NTSC/Clear-QAM of combo/hybrid.  MC knows how to treat as what it is, and it works very, very well (I have not one.)

    That, or an AverTV Combo G2 (which is not as flexible as the ' 2250, where its slightly lower price.)

    HTH,
    Chris

    MS - MVP (Media Center) [If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message.] [Marking a post as answer, or relatively useful, you help others find the answer more quickly.]

  • A consolidated using nested decode question

    Hi Experts,

    I have a requiement as I am trying to solve by nested to decode, but it gives bad result for certain values. I will be grateful for pointers on it. Here's the whole upward for a test case:

    create table test (emp_id varchar2 (20), name varchar2 (20), e-mail varchar2 (100));

    insert into test values ('1 ', 'a',' [email protected]');

    insert into test values ('2 ', null,' [email protected]');

    Insert test values ('3 ', null, null);

    commit;

    The requirement is to print the name if it is not null. If it is null then print email. If the email is also null then print emp_id.

    Here is what I tried:

    select decode(decode(name,null,nvl(email,'xxx')),'xxx',emp_id) from test where emp_id='3';
    
    

    But this gives a null value for emp_id ' 2 'and ' 1'. I don't know where I am going wrong. Please suggest.

    Thank you

    Hello

    If you want to know why the phrase DECODE you posted does not work, it helps to format your code.

    Select decode (decoding (name

    null

    nvl (email, "xxx")

    )

    , "xxx."

    emp_id

    )

    of the test

    where emp_id = '3'

    ;

    This makes it easy to see that the outward expression of DECODE has only 3 arguments.  This means that it will always return NULL or 3rd argument (emp_id).  Clearly, this isn't what you want: you want an expression that sometimes will return name and email, sometimes too.

    As mentioned above, COALESCE seems to be the best way to do what you want.

    Nested NVLs would be another (but of course lower) way.

    CASE is also better than DECODE.

    The following query shows how to get the same results in all these ways:

    SELECT NVL (name

    NVL (e-mail

    emp_id

    )

    )            AS n

    CASE

    WHEN the name IS NOT NULL, THEN name

    WHEN an email IS NOT NULL THEN an email

    Emp_id ELSE

    END AS c

    DECODE (name,

    , NULL, DECODE (e-mail

    NULL, emp_id

    E-mail

    )

    name

    ) AS d

    OF the test

    ;

    Again, I recommend COALESCE for this work.

  • Use the DECODE and RIGHTEOUS in the sql query

    Friends...

    Could someone help with DECODE and sql RIGHT or similar function?

    I'm doing below in the SQL query

    1. DECODE any process with s.process = 1234 to replace with JAVA
    2. RIGHT: Removes all characters after ' @' sign

    SQL query:

    SELECT s.osuser, s.machine, DECODE(s.process, '1234', 'JAVA', right(s.process,charindex('@',s.process)-1)) s.process FROM v$session; 

    for example

    EXAMPLES of data

    User, machine, process

    John, mac1, 1234

    Mike, mac2, 567@mac2

    Julie, mac3, 890


    The result of the SAMPLE:

    User, machine, process

    John, mac1, JAVA

    Mike, mac2, 567

    Julie, mac3, 890

    Thanks in advance

    Thanks guys... I am overwhelmed with all these answers and support on this forum, I received...

    I have combined Solomon and Frank response to achieve accurate result...

    with the answers of Solomon he displayed empty process when there is ' @' sign

    Frank's response showed it process with sign @ the end... so I added '-1' in the end.»

    SELECT s.osuser,

    s.machine,

    DECODE)

    s.Process,

    "1234", "JAVA",

    substr)

    s.Process,

    1,

    InStr)

    s.Process | '@',

    '@'

    ) - 1

    )

    ) process

    V $ session s

    /

  • No output for report of XML editor using CASE/DECODE in a Where Clause

    Hello

    I have a requirement of the company to modify an existing report that has two input parameters,
    -> p_statcode (closed status) which may have values "Y" or "n".
    -> p_overdue (flag late), which can have values of "Y" or "n".

    The flag late is a column evaluated with O/N values and it is evaluated as follows,
    ONTF_MOD_VAL(NVL (
                                         (TRUNC (SYSDATE)
                                          - (TO_DATE (oe_order_lines.attribute18,
                                                      'DD-MON-RRRR')
                                             + TO_NUMBER (fnd_lookup_values.meaning))),
                                         0
                                      ))
                            overdue_flag
    The requirement of user now is that they must be a third option for setting called p_overdue ALL,
    which by the way the output should include records with
    p_statcode is p_statcode ELSE is N AND Y OR p_overdue p_overdue is N

    In other words records with raising the Y and N for flag late must be returned regardless of the value given to the closed state.

    Original where clause contained in the data definition file is as follows,
    WHERE Closed_Status = nvl(:p_statcode,Closed_Status)
                       AND overdue_flag = nvl(:p_overdue,overdue_flag)
    My modified code is the following,
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
             AND overdue_flag = (CASE
             WHEN :p_overdue = 'Y' THEN 'Y'
             WHEN :p_overdue = 'N' THEN 'N'
             ELSE overdue_flag
             END)
    OR
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
             AND overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag)
    Both approaches have the same problem.
    The output is in EXCEL format. The modified query works very well for p_overdue as Y or N but when p_overdue is passed as ALL he returned a blank EXCEL sheet with just exit report column headings.
    Any help regarding, why is this the case? What's not in my approach?

    Kind regards
    Vishal

    unclear on p_overdue = ALL
    P_overdue = ALL on what necessary values?

    try sth like

    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
    AND (
       overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL'
       or
      :p_overdue = 'ALL' and (overdue_flag = 'Y' or overdue_flag = 'N')
    )
    

    for overdue_flag, which has more then 'Y' values of "n".
    If overdue_flag that in ('Y', ' don't) then

    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
    AND (
       overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL'
       or
      :p_overdue = 'ALL'
    )
    
  • Why not always use a X 4 decoder?

    Hello everyone - when using a quadrature encoder when is is benefitial to use a decoder X 2 rather than even if a decoder X 4 proposes to double the resolution angual X 4? Is the existence of X 1, X 2 and X 4 decoders due to the limitation of some Renault which are not compatible with decoding of X 4 and therefore use has no other choice than to use X 2 decoding? Thank you!

    Replica of the wayback machine:

    One of my projects early in the CQI data with LabVIEW learning should take action encoder to characterize the movement.  The advice advanced NOT then was E-series, which did not natively accept quadrature encoders.  We needed an external quadrature decoder circuit which would put a pair of impulse and direction that could handle the E-series.

    The decoder has a DIP switch to choose between X 1 and X 4 of decoding.  It turned out that the measures of quality of movement showed better signal to noise in X 1 in X 4 mode mode.  Further investigation revealed some significant inconsistency in the AB channels.  The phase shift between A & B signals was not terribly close to 90 degrees and their service cycles were not terribly close to 50%.

    X 4 decoding produces 4 pulses per cycle, but they have not been evenly spaced.  This manifests as a fluctuation in speed similar very high frequency adds the background noise of the region we cared about.  For position measurements, we have always used the X 4 b/c despite the systematic phase mode and cycle service errors, he always * some * more information than X 1 mode.

    I do not ever, I chose to use the X 2 mode, but I could see its usefulness where error of cycle for the assignment of the encoder is low, but phase error is high.

    -Kevin P

  • How can I hide the answers on word game cards using Adobe Illustrator to a decoded as a red plexiglass lens?

    I want to print the answers trivia hidden on a word game cards.  Players must use a decoded lens (for example red plexiglass) provided on the map to see the answer.

    What we calls this method and how done in Adobe Illustrator?

    In general, the answer will be composed in a light blue color. The Red darkening can be a pattern of lines or forms, but random characters work as well. The text in red mode value multiply and overlay it on top the blue text. That's about all. The last image is a good approximation of what it will look like when seen through a red filter.

  • Can I use operators to decode those pennies... decode (w_code, 'CH', (pob_desc = 'CART'), pob_desc)

    As in the title of the question

    Depending on whether the value of w_code = "CH", then set the pob_desc to the "CART" whether what it is

    Decode (w_code, 'CH', (pob_desc = 'CART'), pob_desc)

    I get a missing closing parenthesis error

    Hello

    997407 wrote:

    Thanks for the reply,

    I was hoping to use the decoding in a where clause as a predicate clause then if the w_code was CH then the field need to be 'CART' pob_desc else pob_desc.

    DECODE and CASES are not necessary in the clause WHERE; usually, there are easier ways to do everything you need.  For example:

    WHERE (w_code <> 'CH')

    OR pob_desc = "CART".

    )

    If you want to really use DECODE, then do something like:

    WHERE DECODE (w_code

    , 'CH', 'BASKET '.

    pob_desc) = pob_desc

    As always, be careful if the column can be NULL.

    I hope that answers your question.

    If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • PLS 00306 evil type using DECODE


    Hello

    in the hope of finding a quick response and not look too stupid current...

    I have a PL/SQL procedure, I built using a save to spend a required group of data to a package values, I also built.

    Having eliminated all other errors, I finished with the error PLS 00306 wrong number or types of argument.

    To locate the offending entry...

    (1) I made a dummy copy of the procedure called (P1) and (R1) type of record in the package and that returns my driving procedure (P2).

    (2) I progressed to comment on data from a cursor for selecting data in a table P2 (SQL1) spent (P1) as a (R2) record and the corresponding (1) record (P1)

    (3) I enabled each pair of data until I found what column has generated the error.

    There were two...

    One is a field of NVARCHAR2 (F1) to enter in a NCLOB record item, SELECT

    (I'm pretty confident how to get around this - I can't just use a TO_NCLOB on F1 I use a SQL with database connection)

    The other is where I use a DECODE in SQL go to a NVARCHAR2 field (12) (F2)

    SQL1 simplified line... DECODE(COL1,'VAL1','VAL2') F1

    Here's the quesition *.

    I'm guessing that Oracle sees this as a generic string and not a NVARCHAR2 data type

    How can I change the SQL code to avoid the error?

    Thanks for your time (and be gentle with me, please).

    Elaine

    In fact using TO_NCHAR seems to have fixed - must be the string to NVARHCAR2 he had problems with.

    Thanks for posting... Elaine

  • Mark to base using DECODING works is not as expected.

    Version: 11.2.0.3

    Platform: RHEL 5.8

    I try to use the DECODE function.

    In the example below, if the meeting looks for the string 'Enterprise', then decoding should

    return 'Enterprise '. But it doesn't seem to work.

    I thought that some hidden character was the origin of the problem, so I used the TRIM. But no luck.


    SQL > create table t (banner varchar2 (80));

    Table created.

    SQL > insert into values t ('Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production');

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > select * from t;

    BANNER

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

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    SQL > select * from t where the banner as "database % ';

    BANNER

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

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    -Try to use decode it. If the meeting looks for the string 'Enterprise', then return 'Enterprise '.

    -Although the string "Business" is present, decode doesn't seem to work.

    -I tried to use the upper trim. But no luck.


    SQL > select 'EDITION', decode(banner,'%Enterprise%','Enterprise','Standard') edition of t which the banner like '% database % ';

    ' EDITION EDITIO

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

    Standard EDITION

    SQL > select 'EDITION', decode (trim (banner), '% company %', 'Enterprise', 'Standard') edition of t where trim (banner) like '% database;

    ' EDITION EDITIO

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

    Standard EDITION

    SQL > select 'EDITION', decode (upper (trim (banner)), "% COMPANY % ', 'Enterprise', 'Standard') edition of t where upper (trim (banner)) as"DATABASE % ';

    ' EDITION EDITIO

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

    Standard EDITION

    SQL >

    Don't understand why decode cannot see the string "business".

    BTW. Where is the Preview button?

    Hi Ram,

    Decode the will just exactly the result of research and the return value if it matches. This is the way DECODE and CASE work.

    For example: DECODE(deptno,10,'Accounts',20,'IT')

    So please adjust your statement accordnigly. Use INSTR, or REGEXP_COUNT.

    See the example below.

    SELECT decode(regexp_count(banner,'Express'),1,'Express Edition')
    FROM v$version;
    

    In the new forums, I think that we don't have a preview button to see our post before posting.

    See you soon,.

    Suri

  • Decode the statement using the nvl function

    I inherited the code uses a decode and nvl. I'm not sure the purpose of him and wants confirmation that it is logical and an error. The situation can be re-created by implementing the following.

    CREATE TABLE XX_TEST
    (IDENTIFICATION NUMBER,
    DOMAIN VARCHAR2 (255)
    )

    INSERT INTO XX_TEST (ID, FIELD) VALUES (1, 'Yes')
    INSERT INTO XX_TEST (ID, FIELD) VALUES (2, 'No')
    INSERT INTO XX_TEST (ID, FIELD) VALUES (3, NULL)

    Commit

    SELECT ID,
    FIELD,
    DECODE (on the GROUND, the 'yes', ' Yes result this ", NVL (FIELD, 'No'),"no results don't do this","catch all result do this")
    OF XX_TEST

    I'm not sure of the NVL (FIELD, 'No') I think that the creator may have thought this would draw the NULL values, but it is not.
    Null is not converted into no. and plunges into the place the Tote. Can anyone help with an explanation of how oracle is interpretting the select statement. Any ideas on why NVL would be used like that? Seems a mistake?

    decode compares them the first FIELD against NVL (FIELD, 'No').
    If the FIELD is null estimated them VSN none which is not null, then...
    just to make an entry for the null value and one for the 'no' with the same result.
    However, I prefer case statement in this case.

    SELECT ID,
    FIELD,
    case
    when FIELD ='Yes' then 'Yes Result do this'
    when FIELD is null or FIELD = 'No' THen 'No result do this'
    else 'catch all result do this'
    end
    FROM XX_TEST
    

    As more readable.
    concerning

Maybe you are looking for

  • Can I use Virgin Media email and gandi mail net on same Thunderbird set up?

    Having problem for Thunderbird at the second address Virgin Media email see (new) and webmail not much better. If I create a Gandi net account will both my V Media address 1 and new address Gandi be available the same Thunderbird set up? Regards, Phi

  • Qosmio G10-103

    Hello I was wondering if someone could help me with the Qosmio G10 - 103 with 2.0 GHz.I ve seen this laptop Qosmio in several German online shops but I can´t find information on the Toshiba Homepage.Is it a new model yet to be published? If Yes when

  • Demo store on Apple TV 4 mode?

    How can I activate the Demo Mode (shop) on the new Apple TV 4?

  • Satellite P100-106 - sound and modem driver for WXP Pro

    Hello I bought a P100-106 (PSPADE) a few days ago that had Windows Vista Home premium pre-installed. What I tried to do is to install win XP pro SP2 because I realized that Vista not fully cover my needs again. While Toshiba does not support this mod

  • stuck on the installation of office 2010 system restore

    Aspire 5250-0810 pasted on the restoration of the system installation of office 2010, can anyone help