My query is
SELECT *
FROM (
WITH as1 AS (
SELECT
DISTINCT a.COMPANY_NAME,
b.industry_sector,
b.INDUSTRY_GROUP,
c.VERTICAL,
D.VCROUND,
D.VCROUND AS VCROUND1,
D.VCROUND AS VCROUND2,
D.VCROUND AS VCROUND3,
D.VCROUND AS VCROUND4,
D.Deal_date,
e.EMPLOYEE_COUNT ,
a.REVENUE,
a.TOTALRAISED ,
D.Premoney_Valuation
FROM
DAT.PIK.PB_C a
LEFT JOIN D.PIT.PB_COMPANY_INDUS b ON
a.C_ID = b.C_ID
LEFT JOIN D.P.PB_COMPANY_V c ON
c.C_ID = b.C_ID
AND a.C_ID = c.C_ID
LEFT JOIN DA.PIT.PB_DEAL D ON
D.C_ID = c.C_ID
AND D.c_id = b.c_id
AND D.C_ID = a.c_id
LEFT JOIN DA.PITCHBOOK.PB_COMP e ON
e.C_ID = D.C_ID
AND e.C_ID = c.C_ID
AND e.C_ID = b.C_ID
AND e.C_ID = a.C_ID
where a.COMPANY_NAME ='11Sight'
)
SELECT
*
FROM
as1
pivot(sum(TOTALRAISED) FOR VCROUND IN ('Angel', '1st Round', '2nd Round', '3rd Round', '4th Round', '5th Round')) AS p (
COMPANY_NAME,industry_sector,INDUSTRY_GROUP,VERTICAL,Angel_EmployeeCount,
R1_EmployeeCount,R2_EmployeeCount,R3_EmployeeCount,
R4_EmployeeCount,R5_EmployeeCount)
pivot(sum(EMPLOYEE_COUNT) FOR VCROUND1 IN ('Angel', '1st Round', '2nd Round', '3rd Round', '4th Round', '5th Round'))
AS q
).
I am getting 'Angel', '1st Round', '2nd Round', '3rd Round', '4th Round', '5th Round' , . Can you please tell me how to differentiate between columns from top pivot to bottom pivot which gives same columns.