MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 9th, 2003, 06:13 PM
Gabicus Gabicus is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 1 Gabicus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Tring to find the Median

Hi,
I have written some code to find the Average score, only to find that I need to be looking for the Median score. I am not sure how I would go about getting the median instead of the average.

This is what I wrote. Does anyone have any suggestion on what would be the best way to change this code to reflect the median for each set of votes?

Thank you.


select distinct top 5 p.fldTitle 'Production Title',
count(v.idProduction) 'Number of Voters',
avg(v.fldTitleScore) 'Score',
v.idProduction 'Production ID',
m.fldOrganization 'Company',
p.fldContactPerson 'Contact Person',
p.fldContactPhone 'Contact Phone Number',
p.fldContactEmail 'Contact Email'
from wkProductioninfo p,
wkvote v,
wkProductionDate d,
wkMember m
where p.fldPlayMusical = 0
and p.fldWorldPremiere = 1
-- and p.fldSubmitting = 0
and p.fldsolo <> 1
and p.fldTour <> 1
and p.idUser <> '10000000'
and p.idUser <> '10000001'
and p.idUser = m.idUser
and p.idProduction = d.idProduction
and d.fldClosingDate < '09/01/03'
and p.idProduction = v.idProduction
and v.fldTitleScore > .00
group by v.idProduction, p.fldTitle, p.fldContactPerson, p.fldContactPhone, p.fldContactEmail, m.fldOrganization
having(count(v.idProduction) > 8 )
order by avg(v.fldTitleScore) desc
go

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Tring to find the Median


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway