Skip to content

Instantly share code, notes, and snippets.

@prateeka
Created December 4, 2020 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prateeka/697e0c9542dc8727f973f963f66bfc8d to your computer and use it in GitHub Desktop.
Save prateeka/697e0c9542dc8727f973f963f66bfc8d to your computer and use it in GitHub Desktop.
firstChild.name encountering sql group-by error.
SELECT
MIN(t_101.c_44) AS c0,
t_101.c1 AS c1,
t_101.c2s0 AS c2s0
FROM
(
SELECT
MIN(t_98.c_44) AS c_44,
COALESCE(t_100.c_45, t_98.c1) AS c1,
COALESCE(t_100.c_55, t_98.c2s0) AS c2s0
FROM
(
SELECT
t_99.c_55 AS c_55,--pl
t_99.c_68 AS c_68,--pl
t_99.c_69 AS c_69,--psk
t_95.c_45 AS c_45 --pl
FROM
(
SELECT
t_89.c_55 AS c_55,--pl
t_93.c_62 AS c_68,--pl
t_93.c_63 AS c_69--psk
FROM
(
SELECT
dimproduct_t87.productline AS c_55,
dimproduct_t87.productline AS c_56,
dimproduct_t87.productsubcategorykey AS c_57,
RANK() OVER (ORDER BY dimproduct_t87.productline ASC NULLS FIRST ) AS rk_c54,
dimproduct_t87.productline AS c_58
FROM
as_adventure.dimproduct AS dimproduct_t87
WHERE
true
GROUP BY
1,
2,
3,
5
) AS t_89
JOIN
(
SELECT
dimproduct_t90.productline AS c_62,
dimproduct_t90.productsubcategorykey AS c_63,
ROW_NUMBER() OVER (ORDER BY dimproduct_t90.productline ASC NULLS FIRST, dimproduct_t90.productsubcategoryname ASC NULLS FIRST ) AS rn_c61,
dimproduct_t90.productline AS c_66,
dimproduct_t90.productsubcategoryname AS c_67
FROM
as_adventure.dimproduct AS dimproduct_t90
WHERE
true
GROUP BY
1,
2,
4,
5
) AS t_93
ON
t_89.rk_c54 = t_93.rn_c61
GROUP BY
1,
2,
3
) AS t_99
JOIN
(
SELECT
dimproduct_t94.productline AS c_70,
dimproduct_t94.productline AS c_46,
dimproduct_t94.productline AS c_45
FROM
as_adventure.dimproduct AS dimproduct_t94
WHERE
true
GROUP BY
1,
2,
3
) AS t_95
ON
t_99.c_55 = t_95.c_46
WHERE
true
GROUP BY
1,
2,
3,
4
) AS t_100
JOIN
(
SELECT
CAST(dimproduct_t96.productsubcategoryname AS VARCHAR(4096)) AS c_44,
dimproduct_t96.productline AS c1,
dimproduct_t96.productline AS c2s0,
dimproduct_t96.productline AS c_52,
dimproduct_t96.productline AS c_50,
dimproduct_t96.productsubcategorykey AS c_51
FROM
as_adventure.dimproduct AS dimproduct_t96
WHERE
true
GROUP BY
2,
3,
4,
5,
6
) AS t_98
ON
t_100.c_68 = t_98.c_50
AND
t_100.c_69 = t_98.c_51
GROUP BY
2,
3
) AS t_101
GROUP BY
2,
3
ORDER BY
2 ASC NULLS FIRST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment