DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   MS SQL (http://www.daniweb.com/forums/forum127.html)
-   -   (Sum(Sum(MarkU)))/5 (http://www.daniweb.com/forums/thread112804.html)

sbv Mar 8th, 2008 4:23 am
(Sum(Sum(MarkU)))/5
 
Hi

I want to write a query which will return me Sum(MarkU) and also the avg.

Which is something like (Sum(Sum(MarkU)))/5 in mathematically operation

or

TotMark = Sum(MarkU)

AvgMark = TotMark / 5

I hope you get an idea what i need.

How to write this type of query in Db ?

I am using that query for Crystal report.
I tried to get this by using Formula field. But that formula field returning me the result of all rows not for a single row.

Please guide...


Thanks in advance. :)

RamyMahrous Mar 8th, 2008 10:43 am
Re: (Sum(Sum(MarkU)))/5
 
select sum(column1)\5, column2, column3, column4,.... from table1 where some conditions

but
Quote:

I am using that query for Crystal report.
I tried to get this by using Formula field. But that formula field returning me the result of all rows not for a single row.
because you put it in a row so, for each row Crystal report repeats it.. try to define it by some way to avoid that...

sbv Mar 10th, 2008 12:35 am
Re: (Sum(Sum(MarkU)))/5
 
hi RamyMahrous,
Thanks for reply.
As you said in your first query the sum(column1)/5.
Its right. But my requirement is diff. I want sum of a column from database and then depending upon a criteria i need average.

As i mentioned in my earlier post that i tried by using Formula filed in crystal report. And the problem i faced is solved by sending a second column with the sum column.
as i need sum of markU column, so i put a formula as SUM({Query_SS.MarkU},{Query_SS.Dealer})
so i get the sum as per dealer.

Thanks. Have a nice time. :)


All times are GMT -4. The time now is 10:16 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC