lo e intentado pero no me funciona me marca error supongo por el left join,
solo puedo realizar la consulta normal osea de 1 BETWEEN y 2 datetimepicker, mas no cuando deseo unir ambas consultas espero me peudan ayudar muchas gracias.
Código VISUAL:
Ver original
With cmd .CommandType = CommandType.Text .CommandText = "Select NumCta,Nombre,SegNeg, SUM (periodo_pasado) AS Periodo_Pasado, SUM (Cargo) AS Cargo, SUM (Abono) AS Abono, Periodo_Pasado+Cargo-Abono AS SaldoFinal from (Select NumCta,Nombre,SegNeg, SUM (periodo_pasado) AS Periodo_Pasado, SUM (Cargo) AS Cargo, SUM (Abono) AS Abono from (select t1.Fecha,t1.NumCta,t1.Nombre,t1.SegNeg,t1.Cargo,t1.Abono,t1.Saldo_Inicial,t2.saldo_inicial periodo_pasado from(SELECT *FROM mi_vista WHERE Fecha BETWEEN '20120910' AND '20120930') as t1 left join(select NumCta,SegNeg,SUM(cargo) cargo ,SUM(abono) abono ,SUM(saldo_inicial) saldo_inicial from mi_vista WHERE Fecha BETWEEN '20121001' AND '20121007' group by NumCta,Nombre,SegNeg) as t2 on (t1.NumCta=t2.NumCta and t1.NumCta=t2.NumCta)) as completo group by NumCta,Nombre,SegNeg) as x group by NumCta,Nombre,SegNeg,Periodo_Pasado,Cargo,Abono" .Connection = cn End With da.SelectCommand = cmd da.Fill(dt) DataGridView1.DataSource = dt