-- Aumentar campo codigo en institucion finaciera select * from financial_institution; ALTER TABLE `financial_institution` ADD COLUMN `code_fin` VARCHAR(45) NULL AFTER `phone2_fin`; SET SQL_SAFE_UPDATES=0; Pasar los serial_fin ael campo de código instictucion finanaciera update financial_institution set code_fin=serial_fin; select para la vista select distinct pym.name_pym as Forma_Pago, pdt.document_number_pdt as Numero_Documento_de_Pago, pdt.num_check_pdt as Numero_Cheque, fin.name_fin as Institucion_Financiera, phy.serial_phy as Codigo_Factura, phy.subtotal_phy as Subtotal_Factura, phy.taxes_phy as Impuesto_Factura, phy.total_phy as Total_Factura, phy.id_paying_phy as RUC_CI_Factura, phy.name_paying_phy as Cliente_Factura, phy.phone_paying_phy as Telefono_Factura, phy.email_paying_phy as MailFactura, phy.month_phy as Mes, grd.serial_grd as Codigo_Representante, grd.id_grd as Cedula_Representante, concat(grd.first_name_grd,' ',grd.last_name_grd) as Nombre_Representante, grd.email_grd as Mail_Representante, gda.main_street_gda as Calle_principal_domicilio_Representante, gda.number_gda as Numero_Domicilio_Representante, gda.secondary_street_gda as Calle_Secundaria_Represetnante, std.serial_std as Serial_Estudiante, std.code_std as Codigo_Estudiante, std.type_std as Tipo_Estudiante, std.id_std as Cedula_Estudiante, concat(std.first_name_std,' ',std.last_name_std) as Nombre_Estudiante, if(sty.status_sty='REGISTERED','REGISTRADO','NO REGISTRADO') as Estado_Estudiante, sta.main_street_sta as Calle_Principal_Domicilio_Estudiante, sta.number_sta as Numero_domicilio_estudiante, sta.secondary_street_sta as Calle_Secundaria_Domicilio_Estudiante, scy.serial_scy as Codigo_Ano, scy.name_scy as Ano, sct.serial_set as Codigo_Seccion, sct.name_set as Seccion, lvl.serial_lvl as Codigo_Nivel, lvl.name_lvl as Nivel, clg.name_clg as Paralelo, crs.serial_crs as Codigo_Curso, deb.serial_deb as CodigoRubroEstudiante, sva.serial_sva as Codigo_Descuento_Estudiante, sva.serial_ydc as Codigo_Descuento_Ano, dsc.name_dsc as Nombre_Descuento, sva.value_ydv as Valor_Descuento, ypc.serial_ypc as Codigo_Rubro_Ano, pct.serial_pct as Codigo_Catalogo_Concepto_Pago, pct.name_pct as Nombre_Concepto_Pago, phy.taxes_phy as Valor_Impuesto, ypc.value_ypc as Valor_Rubro_Configurado_Nivel from payment_detail pdt join invoice phy on pdt.serial_phy=phy.serial_phy and pdt.status_pdt='ACTIVE' and phy.status_phy='PAID' join invoice_detail psd on phy.serial_phy=psd.serial_phy and status_psd='ACTIVE' join student_year_debts deb on psd.serial_deb=deb.serial_deb and deb.status_deb!='INACTIVE' join year_level_specialty_payment_concept ypc on deb.serial_ypc=ypc.serial_ypc and ypc.status_ypc='ACTIVE' join payment_concept pct on ypc.serial_pct=pct.serial_pct and pct.status_pct='ACTIVE' join specialty spt on ypc.serial_spt=spt.serial_spt and spt.status_spt='ACTIVE' join level lvl on ypc.serial_lvl=lvl.serial_lvl and lvl.status_lvl='ACTIVE' join school_year scy on ypc.serial_scy=scy.serial_scy and scy.status_scy !='INACTIVE' join section sct on ypc.serial_set=sct.serial_set and sct.status_set = 'ACTIVE' join payment_method pym on pdt.serial_pym=pym.serial_pym and pym.status_pym='ACTIVE' left join financial_institution fin on pdt.serial_fin=fin.serial_fin and fin.status_fin = 'ACTIVE' join student std on deb.serial_std=std.serial_std and std.status_std='ACTIVE' join student_guardian stg on std.serial_std=stg.serial_std and stg.status_stg='ACTIVE' and stg.legal_guardian_stg='YES' join guardian grd on stg.serial_grd=grd.serial_grd and grd.status_grd='ACTIVE' join student_year sty on std.serial_std=sty.serial_std and scy.serial_scy=sty.serial_scy and sty.status_sty!='INACTIVE' join student_by_course stc on std.serial_std=stc.serial_std and stc.status_stc='ACTIVE' join course crs ON stc.serial_crs=crs.serial_crs and scy.serial_scy=crs.serial_scy and crs.status_crs='ACTIVE' join class_group clg on crs.serial_clg=clg.serial_clg and clg.status_clg = 'ACTIVE' left join student_year_discount_values sva on psd.serial_sva=sva.serial_sva and sva.status_ydv='ACTIVE' left join year_discount ydc on sva.serial_ydc=ydc.serial_ydc and ydc.status_ydc='ACTIVE' left join discount dsc on ydc.serial_dsc=dsc.serial_dsc and dsc.status_dsc = 'ACTIVE' join student_address sta on sta.serial_sta=(select serial_sta from student_address s where status_sta = 'ACTIVE' and std.serial_std = s.serial_std limit 1) join guardian_address gda on gda.serial_gda=(select serial_gda from guardian_address g where status_gda = 'ACTIVE' and grd.serial_grd = g.serial_grd and g.address_type_gda = 'HOME' limit 1);