Math expression in query

Running Oracle 10g on Solaris 10 SPARC
I have this expression within a query that I would like to round off to the nearest hundreths:
select (x.VALUE/4800.00)*100 as Percentage,
Value is equal to: 4145.22 I want the display to be:86.35 not 86.35875 (or 86.36 if we can round up/down versus truncation)
Thanks

ME_XE?select round(86.35875, 2) from dual;
ROUND(86.35875,2)
             86.36
1 row selected.
Elapsed: 00:00:00.81
ME_XE?
ME_XE?select round(86.35375, 2) from dual;
ROUND(86.35375,2)
             86.35
1 row selected.
Elapsed: 00:00:00.31

Similar Messages

  • How do I render Math expressions in my JSP pages?

    Hi,
    I am sort of a beginner using JSF. I am currently working on a project, where I need to render Math expressions such as fractions, square-roots, power-functions etc.
    The problem is, that currently all I am able to do is to use the standard text operators such as '/', '^' etc. I would like to have 'real' math expressions rendered.
    Does anyone know how to do this easiest? Is there any tag-libs available for doing so?
    I realize it is doable using HTML, but because of the design of my application, it is not an option to insert HTML directly into the JSP pages.
    Thanks in advance :)
    Best Regards
    Thomas

    Thank you for the quick answer!
    My problem is not to do the math, my problem is how to display the math on the JSP page. I want to display fractions, power-functions, square roots with the actual mathmatical symbols, not the symbols mentioned above (/, ^, sqrt, etc.).
    Does anyone know how to do this, or if there exists any taglibs?

  • Using constant expression in query

    When I write a query, if I use a bind variable that could be null as for example:
    select *
    from table
    where :variable is null or column = :variable
    the performance drops significantly.
    I can't find any reason, so if you can help me...
    I also tried something simpler, and something I thought it shoud be faster.
    select *
    from table
    where 1=1 or column = :variable
    this query should return all the table, since 1=1 is allways true. It should be easier to evaluate, since it's the same as before, but it does not need to bind the variable. It takes five times longer than before.
    What I am looking for is to understand what the database does when I run this queries.
    Thankyou very much
    Edited by: user4823534 on 27-abr-2010 9:16

    I think I didn't explain myself.
    I have several very complex querys that use bind variables as optional parameters.
    What I noticed is that it's much slower (100 times maybe) to have a constant expression which is true in an or than evaluating something else. For example
    select * from table where :a is null or column1 in (select column1 from table2 where a = :a) should be faster than
    select * from table where column1 in (select column1 from table2 where a = :a) since the last one has to evaluate the in clause, and the first one is allways true.
    Thankyou for your patience and sorry for my bad english.

  • Reg: Including an expression in query

    Hi All,
    i have a table with two fields like id and expr.
    id is unique.
    And expr contains expressions like
    FirstName||' '||MiddleName||' '||LastName etc ..
    My requirement is i have to write a query to fetch employee information from employee table along with full name by embedding/executing the above expression.
    I can write like this
    Select Employee.*,FirstName||' '||MiddleName||' '||LastName as "Full Name" from Employee.
    But here i know the id value only not the expression itself.
    Select Employee.*,(select Expr from expr_table where id=<id_value>) AS "First Name" from Employee
    It is giving the expression itself instead of executing the expression. It is considering it as a string i think.
    Please suggest me anyone in this regards.
    Thanks in advance,
    Anil Kumar Ch.

    Hi, I dont know how to do it SQL, but you can do it in PL/SQL using EXECUTE IMMEDIATE statement .
    BEGIN
    select Expr INTO v_expr from expr_table where id=<id_value>;
    EXECUTE IMMEDIATE 'SELECT ' || v_expr || ' FROM EMPLOYEE' INTO v_full_name ;
    dbms_output.put_line(v_full_name);
    END;

  • Alias in long math expression

    Sorry the bad english. Im from Brazil.
    Oracle 8.1.7.
    This is just an example for a simple demonstration.
    The following sql runs perfectly:
    select
    1,
    2,
    3,
    (1+2+3) as soma,
    4-(1+2+3),
    (6-(1+2+3)) soma2,
    15-(6-(1+2+3))
    from dual
    Notice that expression (1+2+3) repeats frequently.
    i would like to reduce the sql size using alias (or something like that) for expression (1+2+3) in the same level of dual without using subqueries.
    So, the sql above would stay:
    select
    1,
    2,
    3,
    (1+2+3) as soma,
    4-soma,
    (6-soma) soma2,
    15-soma2
    from dual
    This is perfectly comprehensible, but doesnt work. Oracle says invalid column name for alias soma2 or soma.
    Is there a form to write the sql using alias or hints (and without using subqueries) ?
    Thanks.

    mlinhares,
    I don't think your English is bad :)
    I think you can do what you want by not having to type 1+2+3 every time.
    If you are using SQL*Plus then you could use parameters
    select
    1,
    2,
    3,
    (&&1) as soma,
    4-(&&1),
    (6-(&&1)) soma2,
    15-(6-(&&1))
    from dual
    16:59:34 SQL> l
    1 select
    2 1,
    3 2,
    4 3,
    5 (&&1) as soma,
    6 4-(&&1),
    7 (6-(&&1)) soma2,
    8 15-(6-(&&1))
    9* from dual
    16:59:35 SQL> /
    Enter value for 1: 1+2+3
    1 2
    SOMA 4-(1+2+3)
    15-(6-(1+2+3))
    1 2
    6 -2
    15
    1 row selected.
    Elapsed: 00:00:00.00
    This way you enter the value only once.
    If you want to change this to, say, 2+3+4,
    just do the following:
    SQL > undef 1
    and run the query again. You will be prompted to enter the input again.
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers

  • Need help on Regular expression and query

    Hi Guru's, Hope you all are doing great!.
    I have a scenario's where i need do insert the data into table.
    I have three scenarios :
    select 'Kodali,Raj,S' str from dual
    union
    select 'Alex Romano' from dual
    union
    select 'ppppp' from dual
    Alex Romano
    Kodali,Raj,S
    pppppNow what i want is .
    1. Alex Romano
    if there is space between the string then i want to insert into first name and last name columns
    2. Kodali,Raj,S
    if its a comma between the string then i want to insert into last name , first name and middle name
    3. if there is only one string then same insert into first name and last name.
    I wrote the query earlier to handle only comma and now i am trying but not able to use this all scenarios
    Can you please help me out.
    WITH t AS (
    select 'Kodali,Raj,S' str from dual
    union
    select 'Alex Romano' from dual
    union
    select 'ppppp' from dual
    select DECODE(trim(a),NULL,'a',trim(a)),DECODE(trim(b),NULL,'b',trim(b)),decode(trim(c),NULL,'c' ,trim(c))
    from
      SELECT max(decode(level,1,regexp_substr(str,'[^,]+',1,level))) a --INTO lFNAME
              , max(decode(level,2,regexp_substr(str,'[^,]+',1,level))) b --INTO lLNAME
              , max(decode(level,3,regexp_substr(str,'[^,]+',1,level))) c --INTO lMNAME      
       FROM   t
      CONNECT BY regexp_substr(str,'[^,]+',1,level) IS NOT NULL
      GROUP BY str
    ) ;Currently i am putting a b and c if its null.
    Thanks in advance!

    user590978 wrote:
    Hi Guru's, Hope you all are doing great!.
    I have a scenario's where i need do insert the data into table.
    I have three scenarios :
    select 'Kodali,Raj,S' str from dual
    union
    select 'Alex Romano' from dual
    union
    select 'ppppp' from dual
    Alex Romano
    Kodali,Raj,S
    pppppNow what i want is .
    1. Alex Romano
    if there is space between the string then i want to insert into first name and last name columns
    2. Kodali,Raj,S
    if its a comma between the string then i want to insert into last name , first name and middle name
    3. if there is only one string then same insert into first name and last name.
    I wrote the query earlier to handle only comma and now i am trying but not able to use this all scenarios
    Can you please help me out.
    WITH t AS (
    select 'Kodali,Raj,S' str from dual
    union
    select 'Alex Romano' from dual
    union
    select 'ppppp' from dual
    select DECODE(trim(a),NULL,'a',trim(a)),DECODE(trim(b),NULL,'b',trim(b)),decode(trim(c),NULL,'c' ,trim(c))
    from
    SELECT max(decode(level,1,regexp_substr(str,'[^,]+',1,level))) a --INTO lFNAME
    , max(decode(level,2,regexp_substr(str,'[^,]+',1,level))) b --INTO lLNAME
    , max(decode(level,3,regexp_substr(str,'[^,]+',1,level))) c --INTO lMNAME      
    FROM   t
    CONNECT BY regexp_substr(str,'[^,]+',1,level) IS NOT NULL
    GROUP BY str
    ) ;Currently i am putting a b and c if its null.
    Thanks in advance!It's never a popular suggestion, but why not fix the design to begin with?
    It's the year 2013, can a client not pass you a "complex" data structure consisting of first, middle and last name?
    Why rely on an unreliable construct when there are so many more usable way to achieve this?
    Cheers,

  • New Airport Extreme & Airport Express Setup Query

    Hi,
    About three weeks ago, I purchased my first Wi-Fi router so that I could use my iMac anywhere in the house, but also use my iPhone3G. This was because we do not get Edge coverage where I live in the UK, let alone 3G! And it is very handy to use the iphone when in the garden or my cellar/workshop.
    So I thought I would simplify things and 'keep it in the family' so to speak, as I figured Apple products should work best with each other.
    With this in mind i purchased an +Apple Extreme Base Station 802.11n+. This was very easy to setup and having set the WPA2 Personal Security, it was up and running in about 15 minutes and has worked just great.
    I live in a large bungalow and find that the wi-fi coverage is great in moist areas, including the gardens, but rather weak at one side of the house where we have our home cinema setup and music systems.
    With my pleasant experience with the Extreme in mind, and reading about Airtunes, I bought an +Airport Express 802.11n+ unit a couple of days ago.
    I set it up to join my current Airport Extreme network, and setup my speakers etc as well as iTunes.
    On the whole, the Airtunes aspect is brilliant, apart from the odd drop out from time to time, but my real concern is that my network strength has not improved at all in that area where the Airport Express is is plugged in. It is just as weak as it was when only the Extreme unit was installed.
    I was under the impression that when it joined my Extreme network, the Express unit would extend the network. and it does not appear to have done so at all. On my iPhone3G it shows up as the _very lowest_ signal strength. On my partners Windows laptop, the signal strength is shown as 'poor'.
    Am I doing something wrong, or misunderstanding how the Airport Express works with the Extreme unit?
    All help most welcome.

    Thanks James, I have now an Extended network, and my signal strength is excellent. Once I knew what I was aiming for, it was easy enough.
    Thanks

  • Simple Math in SQL Query or cfset

    Calculated fields in the DB vs <cfset>?
    It would seem simple, but:
    ACCESS DB ;>(
    CF9
    IIS
    <cfquery name="get_total" datasource="#Request.BaseDSN#">
    SELECT SUM((current_charge+penalty)-credit) AS total
    FROM moorings
    WHERE mooring_ID = #URL.mooring_ID#
    </cfquery>
    <cfdump var="#total#"> 
    Variable TOTAL is undefined?
    or
    <cfset subtotal = current_charge+penalty>
    <cfset total = subtotal-credit>
    Variable CURRENT_CHARGE is undefined?
    Missing ',", (, #'s?
    Thanks

    Run the query without using SUM to see what values are stored in the database:
    <cfquery name="get_total" datasource="#Request.BaseDSN#">
    SELECT current_charge, penalty, credit
    FROM moorings
    WHERE mooring_ID = #URL.mooring_ID#
    </cfquery>
    <cfoutput>
    charge: #get_total.current_charge#<br />
    penalty: #get_total.penalty#<br />
    credit: #get_total.credit#<br />
    </cfoutput>
    or
    <cfdump var="#get_total#">
    Also, it's a good idea to get into the habit of using cfqueryparam in your SQL queries. It helps sanitize your inputs and prevents SQL injection attacks:
    <cfquery name="get_total" datasource="#Request.BaseDSN#">
    SELECT current_charge, penalty, credit
    FROM moorings
    WHERE mooring_ID = <cfqueryparam value="#URL.mooring_ID#" cfsqltype="cf_sql_integer">
    </cfquery>

  • Missing expression in query

    Dear all,
    select 'GRANT' || privilege || ' ON ' || OWNER || '.' || TABLE_NAME || from dba_tab_privs where grantee like 'TEST%';
    why the above commands erroring out Missing expression..what Do I have to change ?
    I wish that I should not get mocking answers from the Senior Oracle DBA in this Forum.
    Thanks all
    Kai

    Use
    select 'GRANT '|| privilege || ' ON ' || OWNER || '.' || TABLE_NAME ||' ;' from dba_tab_privs where grantee like 'TEST%';
    This will give the output but what i was thking is TO WHOM is the privilege to be given .That too has to be added in this script
    select 'GRANT '|| privilege || ' ON ' || OWNER || '.' || TABLE_NAME ||' to user_name;' from dba_tab_privs where grantee like 'TEST%';
    Anand
    Edited by: Anand... on Dec 24, 2008 2:20 PM

  • Evaluate math expression

    Hi Guys,
    I need to write java command line program to evaluate a mathematical
    expression input by user without parantheses using Stack approach.
    Can anyone give me the clue how to start of with.
    Is it possible to evaluate the expression in infix notation directly using stack, without converting to prefix notation.
    Thanks in advance

    Is there something nicer?You can also use java 6 and javascripts. I saw a
    thread where someone posted an example.
    KajI posted something a couple of weeks back (reply #2):
    http://forum.java.sun.com/thread.jspa?threadID=5137192
    Of course, you don't need to bind any variables and can do it like this:import javax.script.ScriptEngine;
    import javax.script.ScriptEngineManager;
    import javax.script.ScriptException;
    public class ScriptDemo {
        public static void main(String[] args) {
            ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine engine = manager.getEngineByName("js");
            try {
                String expression = "3+4";
                Object result = engine.eval(expression);
                System.out.println(expression+" = "+result);
            } catch(ScriptException se) {
                se.printStackTrace();
        output: 3+4 = 7.0
    */

  • SQL CASE Expression -need query.

    Hi All , i have query like this
    ----------------SELECT *
    FROM table A
    WHERE 1=1 and CASE WHEN :T=1 THEN (EXISTS
    (SELECT 'x'
    FROM
    (SELECT regexp_substr(str, '[^ ]+', 1, level) str
    FROM
    (SELECT 'SYS TAPE' str FROM dual
    ) t
    CONNECT BY instr(str, ' ', 1, level - 1) > 0
    ) x
    WHERE x.str not in('SYS','APPS')
    AND A.STR LIKE '%'
    || x.str
    || '%'
    )) ELSE A.STR END and a.sr=100;
    Getting errorORA-00905: missing keyword..Please help

    Well, I get other errors:
    SQL> SELECT *
      2  FROM table A
      3  WHERE 1=1 and CASE WHEN :T=1 THEN (EXISTS
      4  (SELECT 'x'
      5  FROM
      6  (SELECT regexp_substr(str, '[^ ]+', 1, level) str
      7  FROM
      8  (SELECT 'SYS TAPE' str FROM dual
      9  ) t
    10  CONNECT BY instr(str, ' ', 1, level - 1) > 0
    11  ) x
    12  WHERE x.str not in('SYS','APPS')
    13  AND A.STR LIKE '%'
    14  || x.str
    15  || '%'
    16  )) ELSE A.STR END and a.sr=100;
    SP2-0552: Bind variable "T" not declared.
    SQL> var T number
    SQL> SELECT *
      2  FROM table A
      3  WHERE 1=1 and CASE WHEN :T=1 THEN (EXISTS
      4  (SELECT 'x'
      5  FROM
      6  (SELECT regexp_substr(str, '[^ ]+', 1, level) str
      7  FROM
      8  (SELECT 'SYS TAPE' str FROM dual
      9  ) t
    10  CONNECT BY instr(str, ' ', 1, level - 1) > 0
    11  ) x
    12  WHERE x.str not in('SYS','APPS')
    13  AND A.STR LIKE '%'
    14  || x.str
    15  || '%'
    16  )) ELSE A.STR END and a.sr=100;
    FROM table A
    ERROR at line 2:
    ORA-00906: missing left parenthesis
    SQL> SELECT *
      2  FROM tableA
      3  WHERE 1=1 and CASE WHEN :T=1 THEN (EXISTS
      4  (SELECT 'x'
      5  FROM
      6  (SELECT regexp_substr(str, '[^ ]+', 1, level) str
      7  FROM
      8  (SELECT 'SYS TAPE' str FROM dual
      9  ) t
    10  CONNECT BY instr(str, ' ', 1, level - 1) > 0
    11  ) x
    12  WHERE x.str not in('SYS','APPS')
    13  AND A.STR LIKE '%'
    14  || x.str
    15  || '%'
    16  )) ELSE A.STR END and a.sr=100;
    WHERE 1=1 and CASE WHEN :T=1 THEN (EXISTS
    ERROR at line 3:
    ORA-00936: missing expressionFrom what I can make of it, looking at the concatenation of x.str in the query, you'll need dynamic SQL.
    Posting a small, working testcase that illustrates your requirement would really help.

  • Expression pedal query.

    Could someone explain whether there are separate jacks for sustain and expression pedals? Do most Midi controllers have these? I’m looking to buy a midi controller I can use with Garritan Gofriller Cello, for which I need both a sustain pedal and expression pedal.
    I was looking to go for something cheap like the M-Audio Keystation 49E. Does anyone know if this would be suitable?
    Thanks for any help you can give and sorry if this is a stupid question. I couldn’t see anything about it when searching on the forum.
    All the best,
    Blair

    Cheers,
    It's more whether they go in the same jack connection that confuses me and what if there is only one jack. Do expression pedals work with most entry-level midi controllers? Should there be two jacks for optimum controllability?

  • CFScript Math expression - Summing up looped over data

    If I loop over numeric data and  I want to sum that data I am looking for the correct manner to do so. Of course I want to do this in cfscript.
    I know that I could go the route of doing a one demensional array and using the array sum function and I could also use stauctures.
    I am interested in different solutions to this problem.
    My end state is that I need to sum and average looped dynamic data for reporting purposes.
    For purposes of example static values will be helpful for better understanding.
    Thanks in advance.

    Owain,
    This is what I came up with and it outputs the looped data. Now I am trying to add it up and average the results.
    BTW Adam,
    Be delusional on a Microsoft or Oracle forum board.
    Now that would be some fun reading cutting through those flames! (In a patronising Kinda Way!).

  • Question on query expression

    I read through the ondemand webservices guide but didn't fiind the answer I was looking for.
    I have a requirement to query Opportunities by setting a multiple search criteria on a single field. For ex, OpportunityConcatField Not equal to VALUE1, VALUE 2 etc.
    If I set only one value in the expression the query works fine. The moment I set more than one value the query bombs out. I read in the forum somewhere that, if I need to set multiple criteria I need to create multiple objects (each with a single criteria) and add them to the list of the input. I would like to avoid it if I can as my criteria is dynamic and is specified in a config file.
    Is there any other alternative ?.
    Thanks

    If i understand your problem correctly, you want to query the records where OpportunityConcatField not equal to VAL1, VAL2,VAL3 etc...
    why don't you use AND operation
    ((<>'VAL1') AND (<>'VAL2)) AND (<>'VAL3') like this.
    Dinesh

  • QueryException Invalid query key in expression.

    Hi, I'm trying to run this select
    Query q = em.createQuery("SELECT R.receivedOn, COUNT(R)) FROM Responders R,"+ "ConsumerHistory ch WHERE ch.jobid = "+job.getJobid()+" and ch.trackid = R.trackid"+ "GROUP BY R.receivedOn");
    the[i] job.getJobid() is a parameter, the exception it throws
    Exception [TOPLINK-6015] (Oracle TopLink Essentials - 9.1 (Build b33e-beta)): oracle.toplink.essentials.exceptions.QueryException
    Exception Description: Invalid query key [jobid] in expression.
    Query: ReportQuery(com.a2mks.scimark.entidad.Responders)
         at oracle.toplink.essentials.exceptions.QueryException.invalidQueryKeyInExpression(QueryException.java:608)
         at oracle.toplink.essentials.internal.expressions.QueryKeyExpression.validateNode(QueryKeyExpression.java:657)
         at oracle.toplink.essentials.expressions.Expression.normalize(Expression.java:2562)
         at oracle.toplink.essentials.internal.expressions.DataExpression.normalize(DataExpression.java:343)
         at oracle.toplink.essentials.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:440)
    The ConsumerHistory Class implementacion is
    @Entity(name = "ConsumerHistory")
    @Table(schema = "SCIMARK", name = "CONSUMER_HISTORY")
    public class ConsumerHistory implements Serializable {
    @Id
    @Column(name = "HISTORYID", nullable = false, length = 20)
    private long historyid;
    @Column(name = "JOBID")
    private long jobid;
    @Column(name = "TRACKID")
    private String trackid;
    Can any body give me some ideas.... thanks

    The specification states that "A property or field name specified as an orderby_item must correspond to a basic persistent property
    or field of the associated class or embedded class within it", so you cannot use type.code since it does not represent a property in Item.
    Please file a feature request if you wish to have this added to EclipseLink as an extension to JPA.

Maybe you are looking for

  • Jar files for using BRM API's

    Hello, I am not able to locate the Jar files for using BRM API's. I have tried searching the forum and did not find the name or location from where I can get them. If they are available on the server I could ask the basis team to give me a copy. Any

  • Fonts Not Showing Up In Illustrator CS5.1

    Hi there,      Would anyone be able to help me, my fonts that are all installed to my computer and that are showing up in Photoshop are not showing up in Illustrator. I have read a few forums on this topic but none seemed helpful. They basicly said t

  • How to debug error 14 during restore?

    all things is ok but my iphone not become restore and i have eror 14.

  • AE SDK wrapper

    Hi I've just been working on a project writing AE plugins - mostly fairly basic things like drawing and animating geometric shapes. This has been my first foray into After Effects plugins. However in doing so I must confess to finding the API painful

  • Aperture Library Importer name is not unique error

    When importing my archival Aperture library into Lightroom I get the error "name is not unique:" and then the name that is not unique. In my case the name in question isn't a project within Aperture but a Facebook album posted long ago using photos f