Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2005, 07:09 AM
Authorized User
 
Join Date: Aug 2005
Location: ankara, , Turkey.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aytacakin
Default ORA-00979: not a GROUP BY expression

I have a SQL code.How can I solve this eror:

---> ORA-00979: not a GROUP BY expression


My SQL code is:


select
      bolge_kodu, bolge_adi,
      il_kodu, il_adi,
      ilce_kodu, ilce_adi,
      bucak_kodu, bucak_adi,
      koy_kodu, koy_adi,
      kullanici_id,
      sum(yeni_isletme_toplam) yeni_isletme_toplam,
      sum(eski_isletme_toplam) eski_isletme_toplam,
      sum(durum1_isletme_toplam) durum1_isletme_toplam,
      sum(durum2_isletme_toplam) durum2_isletme_toplam,
      sum(durum3_isletme_toplam) durum3_isletme_toplam,
      sum(durum4_isletme_toplam) durum4_isletme_toplam,
      sum(durum5_isletme_toplam) durum5_isletme_toplam,
      sum(durum6_isletme_toplam) durum6_isletme_toplam,
      sum(anket_yapilan_toplam) anket_yapilan_toplam,
      sum(kalan) kalan,
      sum(anket_isletme_toplam) anket_isletme_toplam

from
(
      select
            decode(&PBB, 'H',null,b.bolge_kodu) bolge_kodu, decode(&PBB, 'H',null,b.bolge_adi) bolge_adi,
            decode(&PILB, 'H',null,il.il_kodu) il_kodu, decode(&PILB, 'H',null,il.il_adi) il_adi,
            decode(&PILCB, 'H',null,ilc.ilce_kodu) ilce_kodu, decode(&PILCB, 'H',null,ilc.ilce_adi) ilce_adi,
            decode(&PBCKB, 'H',null,bck.bucak_kodu) bucak_kodu, decode(&PBCKB, 'H',null,bck.bucak_adi) bucak_adi,
            decode(&KB, 'H',null,k.koy_kodu) koy_kodu, decode(&KB, 'H',null,NVL(k.koy_adi,'MERKEZ')) koy_adi,
            decode(&KLCB, 'H',null,fb.kullanici_id) kullanici_id,
            sum(decode(c.ciftci_id,null,1,0)) yeni_isletme_toplam,
            sum(decode(c.ciftci_id,null,0,1)) eski_isletme_toplam,
            sum(decode(c.durum,1,1,0)) durum1_isletme_toplam,
            sum(decode(c.durum,2,1,0)) durum2_isletme_toplam,
            sum(decode(c.durum,3,1,0)) durum3_isletme_toplam,
            sum(decode(c.durum,4,1,0)) durum4_isletme_toplam,
            sum(decode(c.durum,5,1,0)) durum5_isletme_toplam,
            sum(decode(c.durum,6,1,0)) durum6_isletme_toplam,
            count(c.sira) anket_yapilan_toplam,
            0 kalan,
            sum(decode(c.ciftci_id,null,0,1)) anket_isletme_toplam
      from
          bolge_duzey2 b,
          trm_il il,
          trm_ilce ilc,
          trm_bucak bck,
          trm_koy k,
          trm_form_b fb,
          trm_ciftci c
      where
           (&PB is null or b.id = &PB) and
           (&PIL is null or il.il_kodu = &PIL) and
           b.id = il.bolge_duzey2_id and
           (&PILC is null or ilc.ilce_kodu = &PILC) and
           il.il_kodu = ilc.il_kodu and
           (&PBCK is null or bck.bucak_kodu = &PBCK) and
           ilc.il_kodu = bck.il_kodu and
           ilc.ilce_kodu = bck.ilce_kodu and
           (&PK is null or k.koy_kodu = &PK) and
           bck.il_kodu = k.il_kodu and
           bck.ilce_kodu = k.ilce_kodu and
           bck.bucak_kodu = k.bucak_kodu and
           k.id = fb.koy_id and
           fb.id = c.formb_id
      group by
            decode(&PBB, 'H',null,b.bolge_kodu) , decode(&PBB, 'H',null,b.bolge_adi) ,
            decode(&PILB, 'H',null,il.il_kodu) , decode(&PILB, 'H',null,il.il_adi) ,
            decode(&PILCB, 'H',null,ilc.ilce_kodu) , decode(&PILCB, 'H',null,ilc.ilce_adi) ,
            decode(&PBCKB, 'H',null,bck.bucak_kodu) , decode(&PBCKB, 'H',null,bck.bucak_adi) ,
            decode(&KB, 'H',null,k.koy_kodu) , decode(&KB, 'H',null,NVL(k.koy_adi,'MERKEZ')) ,
            decode(&KLCB, 'H',null,fb.kullanici_id)
      union all
      select
            decode(&PBB, 'H',null,b.bolge_kodu) bolge_kodu, decode(&PBB, 'H',null,b.bolge_adi) bolge_adi,
            decode(&PILB, 'H',null,il.il_kodu) il_kodu, decode(&PILB, 'H',null,il.il_adi) il_adi,
            decode(&PILCB, 'H',null,ilc.ilce_kodu) ilce_kodu, decode(&PILCB, 'H',null,ilc.ilce_adi) ilce_adi,
            decode(&PBCKB, 'H',null,bck.bucak_kodu) bucak_kodu, decode(&PBCKB, 'H',null,bck.bucak_adi) bucak_adi,
            decode(&KB, 'H',null,k.koy_kodu) koy_kodu, decode(&KB, 'H',null,NVL(k.koy_adi,'MERKEZ')) koy_adi,
            null kullanici_id,
            sum(decode(c.ciftci_id,null,1,0)) yeni_isletme_toplam,
            sum(decode(c.ciftci_id,null,0,decode(c.tip,null,0, 1))) eski_isletme_toplam,
            sum(decode(c.durum,1,1,0)) durum1_isletme_toplam,
            sum(decode(c.durum,2,1,0)) durum2_isletme_toplam,
            sum(decode(c.durum,3,1,0)) durum3_isletme_toplam,
            sum(decode(c.durum,4,1,0)) durum4_isletme_toplam,
            sum(decode(c.durum,5,1,0)) durum5_isletme_toplam,
            sum(decode(c.durum,6,1,0)) durum6_isletme_toplam,
            sum(decode(c.tip,null,0,1)) toplam,
            sum(decode(c.tip,null,1,0)) kalan,
            sum(decode(c.ciftci_id,null,0,1))
      from
          bolge_duzey2 b,
          trm_il il,
          trm_ilce ilc,
          trm_bucak bck,
          trm_koy k,
          trm_ciftci c
      where
           (&PB is null or b.id = &PB) and
           (&PIL is null or il.il_kodu = &PIL) and
           b.id = il.bolge_duzey2_id and
           (&PILC is null or ilc.ilce_kodu = &PILC) and
           il.il_kodu = ilc.il_kodu and
           (&PBCK is null or bck.bucak_kodu = &PBCK) and
           ilc.il_kodu = bck.il_kodu and
           ilc.ilce_kodu = bck.ilce_kodu and
           (&PK is null or k.koy_kodu = &PK) and
           bck.il_kodu = k.il_kodu and
           bck.ilce_kodu = k.ilce_kodu and
           bck.bucak_kodu = k.bucak_kodu and
           k.id = c.koy_id and
           c.formb_id is null
      group by
            decode(&PBB, 'H',null,b.bolge_kodu) , decode(&PBB, 'H',null,b.bolge_adi) ,
            decode(&PILB, 'H',null,il.il_kodu) , decode(&PILB, 'H',null,il.il_adi) ,
            decode(&PILCB, 'H',null,ilc.ilce_kodu) , decode(&PILCB, 'H',null,ilc.ilce_adi) ,
            decode(&PBCKB, 'H',null,bck.bucak_kodu) , decode(&PBCKB, 'H',null,bck.bucak_adi) ,
            decode(&KB, 'H',null,k.koy_kodu) , decode(&KB, 'H',null,NVL(k.koy_adi,'MERKEZ'))
) t
group by
      bolge_kodu, bolge_adi,
      il_kodu, il_adi,
      ilce_kodu, ilce_adi,
      bucak_kodu, bucak_adi,
      koy_kodu, koy_adi,
      kullanici_id


  #2 (permalink)  
Old December 15th, 2005, 12:59 PM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

With a group by expression you have to put all the field that are in the select and not in a group by expression in the order by expression :

ex :
select champ1, champ3, sum(champ2) from table group by champ1, champ3;

And I think that decode in a group by expression is not allowed.

By


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ORA-14100 auxiora_nemesis Oracle 0 April 6th, 2007 04:25 AM
ORA-0134 db009 Oracle 0 February 23rd, 2007 06:04 AM
[Oracle][ODBC][Ora][ORA-01013 Corey Access 1 December 15th, 2006 10:29 AM
Restart new group number in Group Footer sukarso Crystal Reports 2 October 13th, 2006 12:11 PM
ORA-01006 ahrv Java Databases 1 September 20th, 2003 05:45 PM



All times are GMT -4. The time now is 10:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.