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. :)

select sum(column1)\5, column2, column3, column4,.... from table1 where some conditions

but

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...

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. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.