So, Here are the tables-
create table person (
id number,
name varchar2(50)
);
create table injury_place (
id number,
place varchar2(50)
);
create table pe
You will have to first take the count and pct in a subquery then use max+decode function to summarize both of them in the required fashion Check if the below query helps:
SELECT Max(Decode(i.place,'Kitchen',cnt)) AS "Kitchecn"
, Max(Decode(i.place,'Kitchen',pct)) AS "Pct"
, Max(Decode(i.place,'Washroom',cnt)) AS "Washroom"
, Max(Decode(i.place,'Washroom',pct)) AS "Pct"
, Max(Decode(i.place,'Rooftop',cnt)) AS "Rooftop"
, Max(Decode(i.place,'Rooftop',pct)) AS "Pct"
, Max(Decode(i.place,'Garden',cnt)) AS "Garden"
, Max(Decode(i.place,'Garden',pct)) AS "Pct"
FROM (SELECT i.place
, Count(pim.injury_id) AS cnt
, (Count(pim.injury_id)*100/(SELECT Count(*) FROM person_injuryPlace_map)) AS pct
FROM person_injuryPlace_map pim
INNER JOIN injury_place i ON i.id = pim.injury_id
GROUP BY i.place)