I have been working on the ssrs reporting, i task is to get the Fish Max, Min, Avg,Stdev,Medain of length and weight from Catches by group by speciesId , I was able to get Max, Min,Avg of length and weight of each speciesId but the tricky part was get median for length and weight, I have been google for the solution and found different solution but i am not sure which one was right for my case. Here is my temp table
i used SQL 2008
CREATE TABLE #Catchestemp
(
id int, -- Primary key
speciesID int, --foreign key
catchWeight numeric(6,2),
catchLength numeric(6,3)
)
INSERT INTO #Catchestemp (id, speciesID,catchWeight,catchLength)
VALUES
(1,1,500.00,16.000),
(2,1,160.00,25.000),
(3,2,36.00,13.000),
(4,2,15.00,20.000),
(5,3,25.00,25.000),
(6,3,24.00,128.000),
(7,4,26.00,163.000),
(8,5,24.00,172.000),
(9,5,27.00,172.000),
(10,6,27.00,172.000),
(11,6,25.00,158.000),
(12,6,26.00,134.000),
(13,6,28.00,154.000),
(14,1,240.00,133.000),
(15,1,100.00,114.000),
(16,1,90.00,216.000),
(17,1,50.00,168.000),
(18,7,24.00,115.000),
(19,7,25.00,104.000),
(20,7,27.00,136.000),
(21,7,19.00,74.000),
(22,3,19.00,64.000),
(23,1,50.00,147.000),
(24,1,69.00,146.000),
(25,1,80.00,106.000)
SELECT * from #Catchestemp
DROP table #Catchestemp
Please help me get this out, I will be very appreciated all the answer Thank you in advance.