Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Error in query

  1. #1
    Join Date
    Feb 2011
    Posts
    240

    Default Error in query

    Hi,

    this is my query of a table input:

    SELECT
    INT_CARTELLA AS "CARTELLA"
    , INT_COD_COMUNE AS "COD_COMUNE"
    , COMUNI.DESCRIZIONE AS "COMUNE"
    , INT_COD_AREADIS AS "COD_AREADIS"
    , AREADIS.DESCRIZIONE AS "AREADIS"
    , DISTRETTI.COD_ZONA
    , ZONE.DESCRIZIONE_ZONA AS "ZONA"
    , AREADIS.COD_DISTRETTO
    , DISTRETTI.DES_DISTR AS "DISTRETTO"
    , INT_COD_OPER AS "COD_OPERATORE"
    , OPERATORI.COGNOME || OPERATORI.NOME AS "OPERATORE"
    , INT_TIPO_OPER AS "COD_TIPO_OPER"
    , TAB_VOCI.TAB_DESCRIZIONE AS "TIPO_OPER"
    , INT_QUAL_OPER AS "COD_QUAL_OPER"
    , OPERQUAL.DESC_QUALIF AS "QUAL_OPER"
    , INT_CODPRES AS "COD_PRESIDIO"
    , PRESIDI.DESPRES AS "PRESIDIO"
    , INT_AMBDOM AS "AMBDOM"
    , COUNT (*) AS NUMERO
    , NVL (SUM(INT_TEMPO),0) AS "T_ACCESSI"


    FROM SINSNT_TEST.INTERV, SINSNT_TEST.COMUNI, SINSNT_TEST.AREADIS, SINSNT_TEST.ZONE, SINSNT_TEST.DISTRETTI, SINSNT_TEST.PRESIDI, SINSNT_TEST.TAB_VOCI, SINSNT_TEST.OPERQUAL, SINSNT_TEST.OPERATORI

    WHERE INT_COD_COMUNE=COMUNI.CODICE
    AND INT_COD_AREADIS=AREADIS.CODICE
    AND AREADIS.COD_DISTRETTO=DISTRETTI.COD_DISTR
    AND DISTRETTI.COD_ZONA=ZONE.CODICE_ZONA
    AND INT_COD_OPER=OPERATORI.CODICE
    AND INT_QUAL_OPER=OPERQUAL.COD_QUALIF
    AND INT_CODPRES=PRESIDI.CODPRES
    AND TAB_VOCI.TAB_COD='TIPOPE'
    AND INT_TIPO_OPER=TAB_VOCI.TAB_VAL

    I can not understand what is the error

    Thanks

    Mariarita

  2. #2
    Join Date
    Mar 2011
    Posts
    257

    Default

    the question is ... What is the error you are getting ?
    i can guess you probably get an error because you are using a count and a sum with no group by

  3. #3
    Join Date
    Feb 2011
    Posts
    240

    Default

    Yes, but if I add: group by INTERV.INT_TEMP the error is: it is not a expression GROUP BY

  4. #4
    Join Date
    Jun 2011
    Posts
    102

    Default

    Hi,
    you have to put all your field in the group by, not only 1:
    select a,b,c,d,sum(e) as mysum
    from mytable
    group by a,b,c,d

  5. #5
    Join Date
    Mar 2011
    Posts
    257

    Default

    Yes you can't group them on the thing you want to count
    you have to for example place ZONA in the group by and then it will make the sum of INT_TEMPO with all rows with the same ZONA.
    for example... I don't know the data and I don't know what you want to count/sum...

  6. #6
    Join Date
    Feb 2011
    Posts
    240

    Default

    Thanks very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.