Re: [GENERAL] SQL Question - Group By and % results per row

2007-03-15 Thread Bruno Wolff III
On Mon, Mar 12, 2007 at 12:53:11 -0700,
  Mike <[EMAIL PROTECTED]> wrote:
> 
> How do I get access to the total of all clicks on per row basis so I
> can divide it? The only solution that comes to my mind is create a
> subquery that does a (select count(*) from... where... ) of the
> original grouped by sql statement.

That's how you do it.

---(end of broadcast)---
TIP 6: explain analyze is your friend


[GENERAL] SQL Question - Group By and % results per row

2007-03-15 Thread Mike
I have a SQL statement that uses group-by to generate reports as such:


GroupFieldClicks
---
Page 1  50
Page 2  20
Page 3  30

Now, as an added field, I also want it to tell me what percent of
total clicks each row represents.

GroupFieldClicks Percent
---   
Page 1  50   50%
Page 2  20   20%
Page 3  30   30%

How do I get access to the total of all clicks on per row basis so I
can divide it? The only solution that comes to my mind is create a
subquery that does a (select count(*) from... where... ) of the
original grouped by sql statement.

Thank you for your help in advance,
Regards,
Mike


---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match