I try this query from this query i get result with multiple records with same name
SELECT
S.Fruit
,S.RegNo
,SUM(total) total
FROM (SELECT
RV.Fruit
,RV.RegNo
,COUNT(vv.Fruit) as total
, RV.MS
from vv inner join RV on vv.MID= RV.ID
inner join Re on RV.RID=Re.RID
WHERE Reg.SDate>='2016-04-0100:00:00.000' and
Reg.EDate<= '2016-04-30 23:59:59.000' and
Reg.Reg= 'UK' and RV.RegNo ='375' AND
Fruit <> ''
GROUP BY RV.Fruit,RV.RegNo) S
GROUP BY S.Fruit,S.RegNo order by S.Fruit
Output:
Name RegNo total Fruit
John 375 2 Apples
John 375 1 Oranges
John 375 10 Grapes
John 375 2 Pear
John 375 14 Mango
where as i want this output
Name RegNo Apples Oranges Grapes Pear Mango total
John 375 2 1 10 2 14 29
so how to get this result?