Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
manlio78
Starting Member
2 Posts |
Posted - 2009-06-05 : 09:23:07
|
I have this query:select CodLiteral, SUM(Miles*duraSof)/SUM(duraSof) as AscoltoMedio, ( (SUM(Miles * durasof)/ SUM(DURASOF)) / (SUM(ttv*durasof)/SUM(durasof)) *100) as ShareMediofrom histinformativos hi INNER join informa i on hi.codLiteral = i.codigoLit AND i.fecha=hi.fechaWHERE month(i.fecha) = 5 AND year(i.fecha)=2009GROUP BY CodLiteralI want to simplify with a sub query that divide the sums per other sums?...How can I do it?Thank youManlio |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-05 : 13:46:38
|
[code]SELECT CodLiteral, AscoltoMedio, AscoltoMedio*100.0/Sum2 FROM(select CodLiteral, SUM(Miles*duraSof)*1.0/SUM(duraSof) as AscoltoMedio,SUM(ttv*durasof)*1.0/SUM(durasof) AS Sum2 from histinformativos hi INNER join informa i on hi.codLiteral = i.codigoLit AND i.fecha=hi.fechaWHERE month(i.fecha) = 5 AND year(i.fecha)=2009GROUP BY CodLiteral)t[/code] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
manlio78
Starting Member
2 Posts |
Posted - 2009-06-08 : 07:10:53
|
thank youByeManlio |
|
|
|
|
|