DB2 AS400

ID #1003

Problème de calculs numériques avec DB2 (sur AS400):

Problème de calculs numériques avec DB2 (sur AS400):

1)La requête suivante:
SELECT 1/4 FROM SYSIBM.SYSDUMMY1
Retourne 0 !!!!

Solution:
Pour avoir le nombre juste, utiliser la fonction DECIMAL:
SELECT DECIMAL(1.0 * 1/4,13,2)FROM SYSIBM.SYSDUMMY1
Retourne: 0.25


2)La requête suivante:
SELECT 1.0 * 12/24 FROM SYSIBM.SYSDUMMY1
Retourne : .5000000000000000000

Solution:
Pour éliminer ces zéros, utiliser la fonction DECIMAL:
SELECT DECIMAL(1.0 * 12/24,13,3) FROM SYSIBM.SYSDUMMY1
Retourne : .500 NB: 13,3 étant le type décimal voulu à la sortie.

Tags: -

Related entries:

Dernière mise à jour: 2007-12-29 20:15
Auteur: Michel Preti
Révision: 1.0

Digg it! Imprimer cet article Envoyer à un ami version PDF
Propose a translation for Propose a translation for
Merci de noter cette entrée:

Moyenne des notes: 0 sur 5 (0 Votes)

complètement inutile 1 2 3 4 5 indispensable

Vous ne pouvez pas commenter cet enregistrement

Commenté par ygXC2n1K4ye7:
pick up signed coieps Yes, in the two expert sessions I have, we'll be giving away a few coieps (see asktom homepage for info on those sessions). As well we are trying to set up something else in/near the bookstore, but that isn't finalized yet. the title is different This is for this book. Not sure which one you were looking at.
Added at: 2015-12-21 10:29

Commenté par ZPSHhxg8J7Y:
Your site is fine. I just want to comment on the diesgn. Its too loud. Its doing way too much and it takes away from what youve got to say –wch I think is really important. I don’t know if you didnt think that your words could hold everyones attention, but you were wrong.
Added at: 2015-12-22 19:20