diff --git a/src/sqlParser.jison b/src/sqlParser.jison index 4a8efbc..a7abaef 100644 --- a/src/sqlParser.jison +++ b/src/sqlParser.jison @@ -587,6 +587,7 @@ index_hint table_factor : identifier partitionOpt aliasOpt index_hint_list_opt { $$ = { type: 'TableFactor', value: $1, partition: $2, alias: $3.alias, hasAs: $3.hasAs, indexHintOpt: $4 } } | '(' selectClause ')' aliasOpt { $$ = { type: 'TableFactor', value: { type: 'SubQuery', value: $2 }, alias: $4.alias, hasAs: $4.hasAs} } + | '(' unionClauseNotParenthesized ')' aliasOpt { $$ = { type: 'TableFactor', value: { type: 'SubQuery', value: $2 }, alias: $4.alias, hasAs: $4.hasAs} } | '(' table_references ')' { $$ = $2; $$.hasParentheses = true } ; place_holder diff --git a/test/main.test.js b/test/main.test.js index 2ee9c1b..2029b83 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -436,4 +436,45 @@ describe('select grammar support', function () { it('test IDENTIFIER', function () { testParser('select `aa#sfs`(a) as \'A A\' from z'); }); + + it('test from with union select', function (){ + testParser(`select + (select min(actividad) + from + ( select client_id, + (select code_description from m_code_value where code_id =61 and id=LActividadEconomica_cd_own_business_main_activity) actividad, + estimated_amount_income_employer monto + from m_clientDetalleNegocios + union all + select client_id, + (select code_description from m_code_value where code_id =47 and id=Ltipoingreso_cd_income_type) actividad , other_incomes_estimated_amount monto + from m_clientDetalleOtrosIngresos + union all + select client_id, case r.Lsector_cd_Sector when 154 then 755 else 754 end actividad, + r.estimated_incomes_amount monto + from m_clientDetalleRelLaboral r + ) actividades + where monto = + ( select max(monto) + from + ( + select client_id, + (select code_description + from m_code_value where code_id =61 and id=LActividadEconomica_cd_own_business_main_activity) actividad, estimated_amount_income_employer monto + from m_clientDetalleNegocios + union all + select client_id, + (select code_description from m_code_value where code_id =47 and id=Ltipoingreso_cd_income_type) actividad , other_incomes_estimated_amount monto + from m_clientDetalleOtrosIngresos + union all + select client_id, case r.Lsector_cd_Sector when 154 then 755 else 754 end actividad, r.estimated_incomes_amount monto + from m_clientDetalleRelLaboral r + ) maxact + where client_id = actividades.client_id + ) + and client_id =cli.id + ) as c55017 + from m_client cli`) + }) + }); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy