SQL Pivot Table

SQL Pivot Table

Hi,

So I am new to SQL and have been actively learning it whilst we have some time on our hands to improve our reporting.

I need to take data and present it as per a pivoted table the standard pivot function presents the data like this;


What I am trying to achieve is more like this:


So I found the support on pivots and have simplified my model so I can get an understanding (its about 1/3 of the way down);



So I have taken this and adapted it to my needs in a very simple form so I don't get too lost in it, before I fully understand it, so I have created this:

SELECT
"pivot"."Targets/Invoice/Backlog Owner" as "Targets/Invoice/Backlog Owner",
"pivot"."February Target" as "February Target"
FROM (SELECT
"Targets/Invoice/Backlog"."Targets/Invoice/Backlog Owner" as "Targets/Invoice/Backlog Owner",
"Targets/Invoice/Backlog"."February Target"
FROM  "Targets/Invoice/Backlog")
AS  "pivot-source"
pivot
(sum("pivot-source"."Targets/Invoice/Backlog Owner") FOR "pivot-source"."February Target" in ( "Targets/Invoice/Backlog Owner", "February Target"  )
) AS pivottable

Right now the error seems to revolve around line 9, Pivot (I highlighted in red).... or is it the Pivots in the 2nd and 3rd lines causing me issues?
Unknown table or alias 'pivot' used in select query.

am I being dumb, pointers would be nice if you have the time.

Stay safe

Iain 



      • Sticky Posts

      • Announcing Zoho Analytics 6.0 Beta!

        We are delighted to open up the next major version, Zoho Analytics 6.0 Beta! The new version comes packed with a wide range of functionalities for all persona, namely business users, data analysts, data engineers, and data scientists. Zoho Analytics team
      • What's New in Zoho Analytics - August 2024

        Hello Users! We are back with the latest updates and enhancements made to Zoho Analytics. Keep reading to learn more about them. Connect to the data hosted in the cloud without allow-listing the IP addresses Utilize Zoho Databridge to connect to the data
      • We are coming to your city! Zoho Analytics Community Meetup

        Hello, business leaders and data enthusiasts! We are delighted to announce that registrations are now open for the ZUG meetups, and we can't wait for you to be a part of them. Our in-house analytics experts are geared up to lead discussions on constructing
      • Zoho Analytics: 2021 Look Back

        As we start a new year in 2022, here's some of our top moments from 2021. Zoho Analytics in 2021
      • [Customer Talk] PREMO Group's Analyst Interview at Zoho Day 2022

        Premo Group, a 50 year old Spanish Manufacturing Company, has been our long-standing customer with #ZohoAnalytics. They've been using our platform for their end-to-end, unified business analytics solution.  Hear more from Claudio Cabeza, Director at PREMO