Search code examples
sqloracle-databasepivotsyntax-errororacle-sqldeveloper

Oracle Database SQL - Turn Column into a row - String values only - PIVOT


ID (PrimaryKey) HumanAttribut attributValue
1 Name John
1 Country USA

I want to turn a column into a row

like this:

ID (PrimaryKey) Name Country
1 John USA
SELECT ID, (*pink*) [Name], [Country]
FROM
(SELECT ID, HumanAttribut as Ahuman, attributValue
FROM tableA
WHERE ID = 1
AND HumanAttribut IN ('Name', 'Country')) as SourceTabele
PIVOT
(Max(attributeValue)
For
Ahuman in ([Name], [Country])
) as PIVOT_TABLE

I get the error missing expression. Oracle shows me with pink that there is an error.

pink error

If someone already posted something similar like this, with easy values like name or country then pls link it to me.

Thanks for the help in advance!

I followed this video https://www.youtube.com/watch?v=uT_Z2VP2Z24, but I dont know why my syntax is wrong, I know that something is missing through the error message, but I dont know what I forgot...


Solution

    • wrong Syntax, use Oracle db
    • syntax railroad diagramm error
    • syntax error

    I fixed it.