|
Posted by Scripty on 12/18/06 16:48
Thanks Guys,
I will give this a go. Is this T-SQL / pl-SQL or is this a technique
used only on SQL Server ?
Yes, Ed, there's primary keys, indices, etc etc on this table. Just
wanted to post the bare bones of the problem, rather than labour you
with all the other details..
cheers,
Scripty.
Ed Murphy wrote:
> markc600@hotmail.com wrote:
>
> > select date,
> > user,
> > sum(case when transaction_type ='debit' then amount else 0 end)
> > /
> > sum(amount) as perc_Debit
> > from mytable
> > group by date, user
>
> You're right, I guess coalesce() isn't needed. (It would have been
> needed in the temp-tables approach, if you wanted to pick up date/user
> combinations with 0% debits.)
Navigation:
[Reply to this message]
|