Looking for percentage of aggregate, grouped on column value
- From: rloef@xxxxxxxxxxxxx
- Date: 15 Sep 2005 11:57:07 -0700
I'm trying to write a query that will give me a column's (sum(value) in
a date range) as a percentage of that column's sum(value) for all
records, and grouped by a column of types. Something like 'give me #1,
the sum of all values for a column, and #2 the sum of values for the
same column where {some other value) is >= X and <= Y, and then divide
2 by 1 and give the answer to me as a percentage of 1.
The table is fairly vanilla, e.g:
dept
product#
sale_date
price
quant
total
I can plug in different values myself but I'm certainly getting the
construction wrong because I can't seem to build anything mysql wants
to use. Does it take a sub-query? Self-join, outer join, temp duplicate
table?
Thanks for any pointers,
r
.
- Follow-Ups:
- Re: Looking for percentage of aggregate, grouped on column value
- From: Ed Prochak
- Re: Looking for percentage of aggregate, grouped on column value
- Prev by Date: Re: Does anyone know about a good resource on databases
- Next by Date: Re: Does anyone know about a good resource on databases
- Previous by thread: Does anyone know about a good resource on databases
- Next by thread: Re: Looking for percentage of aggregate, grouped on column value
- Index(es):
Relevant Pages
|
|