User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Jan 2008
Location: India
Posts: 141
Reputation: sbv is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
sbv's Avatar
sbv sbv is offline Offline
Junior Poster

Help (Sum(Sum(MarkU)))/5

  #1  
Mar 8th, 2008
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.
Accept Challenges and Enjoy Coding... :)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 743
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 3
Solved Threads: 53
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: (Sum(Sum(MarkU)))/5

  #2  
Mar 8th, 2008
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...
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/
Reply With Quote  
Join Date: Jan 2008
Location: India
Posts: 141
Reputation: sbv is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
sbv's Avatar
sbv sbv is offline Offline
Junior Poster

Re: (Sum(Sum(MarkU)))/5

  #3  
Mar 10th, 2008
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.
Accept Challenges and Enjoy Coding... :)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 10:34 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC