IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SQL Oracle Discussion :

Format d'un champ calculé


Sujet :

SQL Oracle

  1. #1
    Membre averti
    Homme Profil pro
    Inscrit en
    Novembre 2008
    Messages
    611
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2008
    Messages : 611
    Points : 359
    Points
    359
    Par défaut Format d'un champ calculé
    Bonjour,

    Je cherche à formatter un champ numérique calculé à l'affichage sur SQLDEVELOPPER pour ensuite l'exporter sur Excel et faire des calculs.
    Je suis sur Oracle 10g.

    J'ai codé ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    to_char((al.MNT_TOTAL_HT * ucv.ratio_u1_u2 / (al.tot_cmde * uc.ratio_u1_u2) ),'99990,000000')
    Cela me donne un résultat égal à 0.000000.

    Lorsque je code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    al.MNT_TOTAL_HT * ucv.ratio_u1_u2 / (al.tot_cmde * uc.ratio_u1_u2)
    je n'ai pas le même résultat.

    Je souhaiterai avoir le 2ème résultat avec un formattage correct correspondant au 1er.

    Merci d'avance.
    Julien.

  2. #2
    Membre actif
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2011
    Messages : 146
    Points : 263
    Points
    263
    Par défaut
    Bonjour,

    http://download.oracle.com/docs/cd/B...004.htm#i34570

    Que donne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    al.MNT_TOTAL_HT * ucv.ratio_u1_u2 / (al.tot_cmde * uc.ratio_u1_u2)

  3. #3
    Membre averti
    Homme Profil pro
    Inscrit en
    Novembre 2008
    Messages
    611
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2008
    Messages : 611
    Points : 359
    Points
    359
    Par défaut
    Bonjour,

    Je ne parviens pas à formatter le champ calculé tmp.cout_unit avec 6 chiffres avant la virgule et 6 chiffres après. Je souhaite également que mon séparateur de décimales soit la virgule.

    Ma requête SQL:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    select tmp.id_article, tmp.reference, tmp.cout_unit as cout_unit, tmp.num_achat
    from 
      (select a.id_article, al.MNT_TOTAL_HT / (al.NB_LOT_CMDE * al.qte_cmde * al.lg_cmde  as cout_unit, a.reference, b.num_achat
    from t_article a, V_RAPPRO_BL_ACHAT b, t_achat_ligne al
    where a.id_groupe_article in (1,3)
      and a.id_article = b.id_article
      and al.id_achat_ligne = b.id_achat_ligne
      and  a.id_unite_stock = al.id_unite_cmde                          
      and  al.id_unite_cmde <> al.id_unite_tot_cmde  
    union 
    select a.id_article, al.MNT_TOTAL_HT / al.tot_cmde as cout_unit, a.reference, b.num_achat
    from t_article a, V_RAPPRO_BL_ACHAT b, t_achat_ligne al
    where a.id_groupe_article in (1,3)
      and a.id_article = b.id_article
      and al.id_achat_ligne = b.id_achat_ligne
      and  a.id_unite_stock =  al.id_unite_tot_cmde
      and al.id_unite_tot_cmde <> al.id_unite_cmde
    union 
    select a.id_article, al.MNT_TOTAL_HT / al.tot_cmde  as cout_unit, a.reference, b.num_achat
    from t_article a, V_RAPPRO_BL_ACHAT b, t_achat_ligne al
    where a.id_groupe_article in (1,3)
      and a.id_article = b.id_article
      and al.id_achat_ligne = b.id_achat_ligne
      and  a.id_unite_stock =  al.id_unite_tot_cmde
      and al.id_unite_tot_cmde = al.id_unite_cmde
    union  
    SELECT   art.id_article, a.MNT_TOTAL_HT / (a.NB_LOT_CMDE * a.qte_cmde * a.lg_cmde)  as cout_unit, a.reference, b.num_achat
      from  t_article art, V_RAPPRO_BL_ACHAT b, t_achat_ligne a  
      where a.id_achat_ligne = b.id_achat_ligne
       and b.id_article   = art.id_article   
       and    art.id_unite_stock = 1461
       and    a.id_unite_cmde    = 1      
       and    art.id_unite_stock <>     a.id_unite_tot_cmde
    union 
    SELECT   art.id_article, a.MNT_TOTAL_HT * c.ratio_u1_u2/ (a.NB_LOT_CMDE * a.qte_cmde * lg_cmde)  as cout_unit, a.reference, b.num_achat
      from  t_article art, unit_conv c,V_RAPPRO_BL_ACHAT b, t_achat_ligne a
      where c.id_unit_abaque = art.id_unite_abaque    
       and  a.id_achat_ligne = b.id_achat_ligne
       and  b.id_article     = art.id_article
       and  c.id_unit2       = a.id_unite_cmde 
       and  c.id_unit1       = case art.id_unite_stock 
                               when 1461 then 1
                               else 
                               art.id_unite_stock 
                               end
       and    art.id_unite_stock <>     a.id_unite_cmde
       and    art.id_unite_stock <>     a.id_unite_tot_cmde
    union   
    SELECT   art.id_article, a.MNT_TOTAL_HT * 1000 / a.tot_cmde  as cout_unit, a.reference, b.num_achat
      from  t_article art, V_RAPPRO_BL_ACHAT b, t_achat_ligne a 
      where a.id_achat_ligne = b.id_achat_ligne
       and b.id_article   = art.id_article   
       and    art.id_unite_stock = 2
       and    a.id_unite_cmde    = 4      
       and    a.id_unite_cmde    = a.id_unite_tot_cmde   
    union 
    SELECT   art.id_article, a.MNT_TOTAL_HT / (1000 * a.tot_cmde) as cout_unit, a.reference, b.num_achat
      from  t_article art, V_RAPPRO_BL_ACHAT b, t_achat_ligne a  
      where a.id_achat_ligne = b.id_achat_ligne
       and b.id_article   = art.id_article   
       and    art.id_unite_stock = 4
       and    a.id_unite_cmde    = 2      
       and    a.id_unite_cmde    = a.id_unite_tot_cmde
    union
    select a.id_article,al.MNT_TOTAL_HT * ucv.ratio_u1_u2 / (al.tot_cmde * uc.ratio_u1_u2) as cout_unit, a.reference, ach.num_achat
    from t_article a, unit_conv uc, V_RAPPRO_BL_ACHAT b, t_achat_ligne al, unit_conv ucv, t_achat ach
     where a.id_article = b.id_article
       and a.id_unite_stock = uc.id_unit2
       and al.id_achat_ligne = b.id_achat_ligne
       and al.id_unite_cmde = uc.id_unit1
       and a.id_unite_abaque = ucv.id_unit_abaque
       and al.id_achat = ach.id_achat) tmp
    Merci d'avance.
    Julien.

  4. #4
    Expert confirmé
    Avatar de laurentschneider
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Décembre 2005
    Messages
    2 944
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2005
    Messages : 2 944
    Points : 4 926
    Points
    4 926
    Par défaut
    la virgule, c'est le séparateur international des milliers

    donc

    to_char('...','99990.000000')

    ou si tu veux qqch de local

    to_char('...','99990D000000')

    avec D{ot} comme séparateur décimal

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2010] Format champ calculé en % dans TCD
    Par Denis_67 dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 27/02/2014, 21h37
  2. Format date / heure dans un champ calculé
    Par Zebulon777 dans le forum Access
    Réponses: 2
    Dernier message: 25/10/2013, 08h06
  3. [AC-2007] Requête : Imposer le format d'un champ calculé de type Numérique
    Par sophie) dans le forum Access
    Réponses: 7
    Dernier message: 13/01/2012, 21h44
  4. [AC-2007] Format dans champ calculé
    Par Nounours1 dans le forum VBA Access
    Réponses: 5
    Dernier message: 28/03/2010, 22h03
  5. Réponses: 2
    Dernier message: 31/10/2007, 14h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo