•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 374,006 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,845 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 511 | Replies: 2
![]() |
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.
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.
Accept Challenges and Enjoy Coding... :)
select sum(column1)\5, column2, column3, column4,.... from table1 where some conditions
but
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...
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.
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
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.
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.
Accept Challenges and Enjoy Coding... :)
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
Other Threads in the MS SQL Forum
- Previous Thread: deleteting multiple rows and related table entries
- Next Thread: How to insert big html markup with white spaces(i.e. line breaks) and single and ...


Linear Mode