I have this query,
(SELECT
[NAME],
[NAME] AS RESULT,
' - ' AS VALUE,
0 AS ORDERING
FROM
[PARTY_MSTR]
UNION ALL
(SELECT
[PARTY_MSTR].[NAME],
' - ' || [T1].[T_NAME],
(SELECT [T2].[T_NAME],
SUM(COALESCE([T2].[VALUE1], 0)) + FROM [T2]
CROSS JOIN [T1] ON [T1].[T_NAME] = [T2].[T_NAME]
GROUP BY [T2].[T_NAME]),
1
FROM
[PARTY_MSTR]
CROSS JOIN [T1]
) AS X;
When I run this query, I got this error SELECTs to the left and right of UNION ALL do not have the same number of result columns
Now I remove the comments, and the second error comes, only a single result allowed for a SELECT that is part of an expression
. What's wrong with this queries.? I am using SQLite database.