How can I reformulate this query without using the AS keyword?
P粉765570115
P粉765570115 2024-01-16 20:23:51
0
1
384

I'm completing a HackerRank challenge, but the documentation says I shouldn't use the AS keyword:

I need to rewrite this query in MySQL so that it does not contain the AS in WITH A AS nor the SELECT...AS test AS

WITH A AS (
    SELECT DISTINCT
        MAX( LENGTH( customer_id ) ) AS test
    FROM
        orders

    UNION

    SELECT DISTINCT
        MIN( LENGTH( customer_id ) )
    FROM
        orders
)
SELECT
    test,
    LENGTH(test)
FROM
    A

P粉765570115
P粉765570115

reply all(1)
P粉497463473

WITH clause is used to declare VIEW, so you can rewrite it like below

SELECT
    test,
    LENGTH(test)
FROM
    (
 SELECT DISTINCT
        MAX( LENGTH( customer_id ) ) AS test
    FROM
        orders

    UNION

    SELECT DISTINCT
        MIN( LENGTH( customer_id ) )
    FROM
        orders)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!