I am running this query on MySQL.
Select Vendor, sum(Rate) as Rate
from (select case Vendor when 'NSN' then 'Nokia' else Vendor end as Vendor, Rate
from ( Select vendor ,(count(1) )*100/(Select count(id_incident)from incident where open_time between '2015-01-01'and'2015-01-30') as Rate from incident where open_time between '2015-01-01'and'2015-01-30'group by upper (vendor) )) as y group by vendor;
and it is giving this error:
Error code 1248, SQL state 42000: Every derived table must have its own alias".
what's the problem?
You forgot to give the inner subquery an alias. I chose x
Select Vendor, sum(Rate) as Rate
from
(
select case Vendor when 'NSN' then 'Nokia' else Vendor end as Vendor, Rate
from
(
Select vendor ,(count(1) )*100/(Select count(id_incident)from incident where open_time between '2015-01-01'and'2015-01-30') as Rate
from incident
where open_time between '2015-01-01'and'2015-01-30'
group by upper (vendor)
) as x
) as y
group by vendor;