Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to create median function?

Answer Posted / Gourav Kumar Rastogi

In SQL Server Reporting Services, you can create a median function by using a windowed function like MEDIAN. However, MEDIAN is not supported in all SQL Server versions. As an alternative, you can write your own median function as follows:n`nCREATE FUNCTION dbo.Median (@pData FLOAT) nRETURNS FLOAT AS BEGIN nDECLARE @count INT = (SELECT COUNT(*) FROM @pData) nORDER BY pData nSET @pData = (SELECT TOP ((@count + 1) / 2) pData FROM @pData WHERE ORDER BY pData > @counter) nIF (@count % 2 = 0) nBEGIN n SET @pData = (@pData + (SELECT TOP 1 pData FROM @pData WHERE ORDER BY pData < @counter)) / 2 nEND nRETURN @pData nENDn

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category