Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ORA-00979
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tim Slattery  
View profile  
 More options Oct 24 2012, 3:23 pm
Newsgroups: comp.databases.oracle.misc
From: Tim Slattery <Slatter...@bls.gov>
Date: Wed, 24 Oct 2012 15:23:21 -0400
Local: Wed, Oct 24 2012 3:23 pm
Subject: ORA-00979
I'm getting this error message:

ORA-00979: not a GROUP BY expression ORA-06512: at
"IPP.IPP_GETCURRENTPRICE", line 17 ORA-06512: at line 1

Which points to this statement in a function:

     OPEN cv_1 FOR
         SELECT item_code,
                index_date,
                price,
                currency_code,
                price_basis,
                not_traded,
                price_estimated,
                no_change,
                is_valid
           FROM ipp_price
          WHERE item_code = v_code
           GROUP BY item_code

            HAVING index_date = MAX(index_date);

The value being passed in for v_code is correct. What is it objecting
to?

--
Tim Slattery
Slatter...@bls.gov


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joel garry  
View profile  
 More options Oct 24 2012, 3:42 pm
Newsgroups: comp.databases.oracle.misc
From: joel garry <joel-ga...@home.com>
Date: Wed, 24 Oct 2012 12:42:27 -0700 (PDT)
Local: Wed, Oct 24 2012 3:42 pm
Subject: Re: ORA-00979
On Oct 24, 12:23 pm, Tim Slattery <Slatter...@bls.gov> wrote:

Perhaps the index_date not being in a group by?

Maybe you need a subquery that has the select for the max date in it.

jg
--
@home.com is bogus.
EXT4 Data Corruption Bug Hits Stable Linux Kernels
http://www.phoronix.com/scan.php?page=news_item&px=MTIxNDQ


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Geoff Muldoon  
View profile  
 More options Oct 24 2012, 5:24 pm
Newsgroups: comp.databases.oracle.misc
From: Geoff Muldoon <geoff.muld...@trap.gmail.com>
Date: Thu, 25 Oct 2012 08:24:44 +1100
Local: Wed, Oct 24 2012 5:24 pm
Subject: Re: ORA-00979
Slatter...@bls.gov says...

If you only want the row for MAX(index_date) then you should SELECT
that, not use it in a HAVING clause.  Then you will need to GROUP BY
every other column that has not had an aggregation/function applied to
it.

OPEN cv_1 FOR
    SELECT
        item_code,
        MAX(index_date) as index_date,
        price,
        currency_code,
        price_basis,
        not_traded,
        price_estimated,
        no_change,
        is_valid
    FROM ipp_price
    WHERE item_code = v_code
    GROUP BY
        item_code
        price,
        currency_code,
        price_basis,
        not_traded,
        price_estimated,
        no_change,
        is_valid;

GM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Slattery  
View profile  
 More options Oct 25 2012, 12:54 pm
Newsgroups: comp.databases.oracle.misc
From: Tim Slattery <Slatter...@bls.gov>
Date: Thu, 25 Oct 2012 12:54:52 -0400
Local: Thurs, Oct 25 2012 12:54 pm
Subject: Re: ORA-00979

Geoff Muldoon <geoff.muld...@trap.gmail.com> wrote:
>If you only want the row for MAX(index_date) then you should SELECT
>that, not use it in a HAVING clause.  Then you will need to GROUP BY
>every other column that has not had an aggregation/function applied to
>it.

Thanks, looks like that's it.

I'm converting an application from Sybase to Oracle. The SQL statement
I posted ran perfectly fine in Sybase. Different SQL dialects, I
suppose.

--
Tim Slattery
Slatter...@bls.gov


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joel garry  
View profile  
 More options Oct 25 2012, 7:51 pm
Newsgroups: comp.databases.oracle.misc
From: joel garry <joel-ga...@home.com>
Date: Thu, 25 Oct 2012 16:51:37 -0700 (PDT)
Local: Thurs, Oct 25 2012 7:51 pm
Subject: Re: ORA-00979
On Oct 25, 9:54 am, Tim Slattery <Slatter...@bls.gov> wrote:

> Geoff Muldoon <geoff.muld...@trap.gmail.com> wrote:
> >If you only want the row for MAX(index_date) then you should SELECT
> >that, not use it in a HAVING clause.  Then you will need to GROUP BY
> >every other column that has not had an aggregation/function applied to
> >it.

> Thanks, looks like that's it.

> I'm converting an application from Sybase to Oracle. The SQL statement
> I posted ran perfectly fine in Sybase. Different SQL dialects, I
> suppose.

> --
> Tim Slattery
> Slatter...@bls.gov

Hmmm, yes, this thing says it's a t-sql extension to the standard (and
implies the Oracle one is also a different extension to the standard,
though I haven't thought it through):
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.as...
v. http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_1000...

jg
--
@home.com is bogus.
http://flickrhivemind.net/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Nilsson  
View profile  
 More options Oct 29 2012, 8:37 pm
Newsgroups: comp.databases.oracle.misc
From: Peter Nilsson <ai...@acay.com.au>
Date: Mon, 29 Oct 2012 17:37:27 -0700 (PDT)
Local: Mon, Oct 29 2012 8:37 pm
Subject: Re: ORA-00979
On Oct 25, 8:24 am, Geoff Muldoon <geoff.muld...@trap.gmail.com>
wrote:

Your misunderstanding of the group by concept, the purpose of which is
to aggragate over combinations of values from one or more columns (in
general.) By selecting a column without aggragation, you're saying you
want every row combination including values from that column.

So your query is saying give me a row for every combination of
item_code,
index_date, price, currency_code, price_basis, not_traded,
price_estimated,
no_change and is_valid, BUT only return one row for each item_code.

> If you only want the row for MAX(index_date) then you should SELECT

                   ^^^^^^^
You're assuming there is only one such row.

That will still return multiple rows for a given item_code if any of
the
other columns differ for different index_date entries.

It is similar to...

    select p1.item_code,
           p1.index_date,
           p1.price,
           p1.currency_code,
           p1.price_basis,
           p1.not_traded,
           p1.price_estimated,
           p1.no_change,
           p1.is_valid
      from ipp_price p1
     where p1.item_code = v_code
       and p1.index_date =
             (select max(p2.index_date)
                from ipp_price p2
               where p2.item_code       = p1.item_code
                 and p2.price           = p1.price
                 and p2.currency_code   = p1.currency_code
                 and p2.price_basis     = p1.price_basis
                 and p2.not_traded      = p1.not_traded
                 and p2.price_estimated = p1.price_estimated
                 and p2.no_change       = p1.no_change
                 and p2.is_valid        = p1.is_valid);

Whereas I suspect the OP wants something more akin to...

    select p1.item_code,
           p1.index_date,
           p1.price,
           p1.currency_cde,
           p1.price_basis,
           p1.not_traded,
           p1.price_estimated,
           p1.no_change,
           p1.is_valid
      from ipp_price p1
     where p1.item_code = v_code
       and p1.index_date =
             (select max(p2.index_date)
                from ipp_price p2
               where p2.item_code = p1.item_code);

This too assumes that item_code and index_date form a unique key on
ipp_price,
in which case, the following does the same but is generally more
efficient...

    select item_code,
           max(index_date)      keep (dense_rank last order by
index_date) as index_date,
           max(price)           keep (dense_rank last order by
index_date) as price,
           max(currency_code)   keep (dense_rank last order by
index_date) as currency_cde,
           max(price_basis)     keep (dense_rank last order by
index_date) as price_basis,
           max(not_traded)      keep (dense_rank last order by
index_date) as not_traded,
           max(price_estimated) keep (dense_rank last order by
index_date) as price_estimated,
           max(no_change)       keep (dense_rank last order by
index_date) as no_change,
           max(is_valid)        keep (dense_rank last order by
index_date) as is_valid
      from ipp_price
     where item_code = v_code
     group by item_code;

--
Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »