Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: newbie syntax question
On Thu, 21 Jun 2007 14:30:04 -0700, justsomeschmuck_at_hotmail.com wrote:
>On Jun 21, 2:51 pm, "Chris Colclough"
><chris.colclough_at_no_spam.jhuapl.edu> wrote:
>> Distinct may not be needed.
>
>In my case, the DISTINCT is needed for this reason...
>
>The source table is Orders o. This table has many rows of unique
>OrderIDs. Any number of these order rows can be in the same
>OrderGroup, having the same OrderGroupID & OrderGroupTotal values.
>Thus to get back a rowset of unique OrderGroupIDs and their
>resepective totals, I need the DISTINCT keyword.
>
>> Try the following to get a grand total as a repeating value in the last
>> column:
>
>that was something i had tried earlier, but its not quite right. the
>SUM will sum ALL instances of the OrderGroupTotal matching the WHERE
>clause (status = 2), whereas i only want to sum each distinct
>OrderGroup.
>
>
>Thanks,
>
>John
Regrettably it is quite clear the design is flawed, as the
ordergrouptotal is denormalized.
You need to revise the design instead of starting to implement kludges
like you describe above.
-- Sybrand Bakker Senior Oracle DBAReceived on Thu Jun 21 2007 - 17:01:06 CDT