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 






                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation


                                        Manage your brands on social media



                                              Zoho TeamInbox Resources

                                                Zoho DataPrep Resources



                                                  Zoho CRM Plus Resources

                                                    Zoho Books Resources


                                                      Zoho Subscriptions Resources

                                                        Zoho Projects Resources


                                                          Zoho Sprints Resources


                                                            Qntrl Resources


                                                              Zoho Creator Resources


                                                                Zoho WorkDrive Resources



                                                                  Zoho Campaigns Resources

                                                                    Zoho CRM Resources

                                                                    • CRM Community Learning Series

                                                                      CRM Community Learning Series


                                                                    • Tips

                                                                      Tips

                                                                    • Functions

                                                                      Functions

                                                                    • Meetups

                                                                      Meetups

                                                                    • Kbase

                                                                      Kbase

                                                                    • Resources

                                                                      Resources

                                                                    • Digest

                                                                      Digest

                                                                    • CRM Marketplace

                                                                      CRM Marketplace

                                                                    • MVP Corner

                                                                      MVP Corner

                                                                    





                                                                    




                                                                        Design. Discuss. Deliver.

                                                                        Create visually engaging stories with Zoho Show.

                                                                        Get Started Now