Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Plsql] pivot_clause and unpivot_clause can have own alias #4363

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

jiefei30
Copy link
Contributor

SELECT s2.id, name, subject, score
FROM scores2 s1
    UNPIVOT (
    score FOR subject IN (
        chinese_score AS 'Chinese',
        math_score AS 'Math',
        english_score AS 'English'
    )
) s2;

Here it is, pivot_clause and unpivot_clause can have own alias.
Previous query and its pivot_clause can both have an alias, but pivot_clause's alias will replace previous query alias.
which meas

SELECT s1.id, name, subject, score
FROM scores2 s1
    UNPIVOT (
    score FOR subject IN (
        chinese_score AS 'Chinese',
        math_score AS 'Math',
        english_score AS 'English'
    )
) s2;

if you use s1 to be the identifier will be wrong.
i tried these sql on livesql.oracle.com

@teverett
Copy link
Member

@jiefei30 could you add a test case for this please?

@jiefei30
Copy link
Contributor Author

@teverett I added two cases in /example folder : pivot14.sql, pivot15.sql

@teverett
Copy link
Member

@jiefei30 thanks!

@teverett teverett merged commit 7f917ad into antlr:master Dec 22, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants