|
Home > Archive > MS SQL Server DTS > July 2005 > Multiplying Grouped Columns
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Multiplying Grouped Columns
|
|
|
| I have a query, which selects three columns from an inner join. The last two
columns are SUM and the first one is GROUP BY. Now, I would like to add
another column that will be the multiplication of the second and third
columns. I have tried many ways but I am not very sure if what I have come up
with is the best approach. Could someone suggest what would be the best way
to achieve something like this?
| |
| Narayana Vyas Kondreddi 2005-07-27, 1:28 pm |
| Could you post your query first, along with table structures, sample data
and desired output? Otherwse we'll be guessing what you are trying to
achieve. Anyway, here's a guess:
select i, sum(j), sum(k), sum(j) * sum(k) from x group by i
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @ http://vyaskn.tripod.com/
"HLong" <HLong@discussions.microsoft.com> wrote in message
news:48F966FD-3B4B-4E5D-80AB- 76734EB3826E@microso
ft.com...
>I have a query, which selects three columns from an inner join. The last
>two
> columns are SUM and the first one is GROUP BY. Now, I would like to add
> another column that will be the multiplication of the second and third
> columns. I have tried many ways but I am not very sure if what I have come
> up
> with is the best approach. Could someone suggest what would be the best
> way
> to achieve something like this?
| |
|
| Thank you very much. It was what I was looking for. I didn't know I could
do something like sum(J)*sum(k) :-(
"Narayana Vyas Kondreddi" wrote:
> Could you post your query first, along with table structures, sample data
> and desired output? Otherwse we'll be guessing what you are trying to
> achieve. Anyway, here's a guess:
>
> select i, sum(j), sum(k), sum(j) * sum(k) from x group by i
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @ http://vyaskn.tripod.com/
>
>
> "HLong" <HLong@discussions.microsoft.com> wrote in message
> news:48F966FD-3B4B-4E5D-80AB- 76734EB3826E@microso
ft.com...
>
>
>
|
|
|
|
|