How to create median function?
Answer / 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 |
Would you store your query in a ssrs report or a database server? State the reason why?
What is report server project?
When to use null data driven subscription?
What are parameterized reports?
How to create “dependant” parameter “make, model, year”
What are the export options of ssrs?
What is the report builder?
What is the report model project?
Explain can you implement data mining in ssrs?
How do users use Report Builder with SQL Server data sources?
What are drillthrough reports?
What is rs.exe utility?