[NEWSboard IBMi Forum]
  1. #1
    Registriert seit
    Feb 2002
    Beiträge
    164

    sql variable definieren bzw. runden

    hallo Leute,
    wie kann ich variable "var_x" so definieren bzw. runden,
    dass im sql-Ergebnis nur max. 2 Dezimalstellen angezeigt werden:

    select datei_1.var_1, datei_1.var_2,
    var_1/var_2 as var_x
    from...

    Vielen Dank

  2. #2
    Registriert seit
    Apr 2004
    Beiträge
    105
    Code:
    >>-ROUND--(--expression-1--,--expression-2--)------------------><
    expression–1
    An expression that returns a value of any built-in numeric, character-string, or graphic-string data type. A string argument is converted to double-precision floating point before evaluating the function. For more information on converting strings to double-precision floating point, see DOUBLE_PRECISION or DOUBLE.
    expression–2
    The argument must be an expression that returns a value of a built-in BIGINT, INTEGER, or SMALLINT data type.

    If expression–2 is positive, expression–1 is rounded to the expression–2 number of places to the right of the decimal point.

    If expression–2 is negative, expression–1 is rounded to 1 + (the absolute value of expression–2) number of places to the left of the decimal point. If the absolute value of expression–2 is greater than the number of digits to the left of the decimal point, the result is 0. (For example, ROUND(748.58,-4) returns 0.)
    Quelle: SQL Reference

    In deinem Fall:
    Code:
    select datei_1.var_1, datei_1.var_2,
    ROUND(var_1/var_2, 2) as var_x
    from...

  3. #3
    Registriert seit
    Feb 2002
    Beiträge
    164

    hallo Woki,

    klappt vorzüglich.

    Vielen Dank

Similar Threads

  1. Fehler im SQL bzw. Joblog
    By GraueEminenz in forum NEWSboard Programmierung
    Antworten: 1
    Letzter Beitrag: 10-07-06, 11:58
  2. Generische Felddefinition bzw Generische SQL Ausgabe
    By Rincewind in forum NEWSboard Programmierung
    Antworten: 13
    Letzter Beitrag: 03-06-05, 10:56
  3. CL Variable an SQL übergeben
    By Jenne in forum NEWSboard Programmierung
    Antworten: 3
    Letzter Beitrag: 23-08-04, 10:45
  4. für SQL Profis: Preisliste runden mit SQL
    By hs in forum IBM i Hauptforum
    Antworten: 5
    Letzter Beitrag: 30-01-02, 11:37
  5. Runden über SQL Hiiiiilfe!!!!
    By infomio in forum IBM i Hauptforum
    Antworten: 7
    Letzter Beitrag: 27-11-01, 19:31

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •