I have the below sql query in MSSQL.
SELECT
ap.[AccountId],
(SELECT COUNT(*) FROM [Transactions] t WHERE t.[AccountId] = ap.[AccountId]) AS TransactionCount
FROM
[AccountProfiles] ap
I am using the Parser class and the columns_dict method contains the SELECT sql clause which do not take into account the subqueries.
parser = Parser(subquery)
tables = parser.tables
columns_dict = parser.columns_dict
As you can see from the sql query and the final output below in json format, in the Tables section registers the table from the subquery. In Select clause it does not contain the TransactionCount and it also takes the Where clause which is contained inside the subquery.
{
"Tables": [
"[Transactions]",
"[AccountProfiles]"
],
"Select": [
"[AccountProfiles].[AccountId]"
],
"Where": [
"[Transactions].[AccountId]",
"[AccountProfiles].[AccountId]",
"*"
]
}
I have the below sql query in MSSQL.
I am using the
Parserclass and thecolumns_dictmethod contains theSELECTsql clause which do not take into account the subqueries.As you can see from the sql query and the final output below in json format, in the
Tablessection registers the table from the subquery. InSelectclause it does not contain theTransactionCountand it also takes theWhereclause which is contained inside the subquery.{ "Tables": [ "[Transactions]", "[AccountProfiles]" ], "Select": [ "[AccountProfiles].[AccountId]" ], "Where": [ "[Transactions].[AccountId]", "[AccountProfiles].[AccountId]", "*" ] }