Power Builder - Se puede hacer esto en PB?

 
Vista:
Imágen de perfil de Antonio
Val: 176
Bronce
Ha mantenido su posición en Power Builder (en relación al último mes)
Gráfica de Power Builder

Se puede hacer esto en PB?

Publicado por Antonio (1271 intervenciones) el 12/03/2014 20:25:16
Buen día a todos:

Reciban un cordial saludo,

Tengo una duda con respecto a cierta programación, este ejemplo que les pongo esta creado en un Store Procedure en SQL Server 2008 y quiero saber si de alguna otra manera se puede programar en PB.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Select Datepart(Year,f.fecha_hora) As Año, cc.Descripcion As Familia,
		Sum(Case When Datepart(Month,f.fecha_hora) = 1  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Enero,
		Sum(Case When Datepart(Month,f.fecha_hora) = 2  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Febrero,
		Sum(Case When Datepart(Month,f.fecha_hora) = 3  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Marzo,
		Sum(Case When Datepart(Month,f.fecha_hora) = 4  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Abril,
		Sum(Case When Datepart(Month,f.fecha_hora) = 5  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Mayo,
		Sum(Case When Datepart(Month,f.fecha_hora) = 6  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Junio,
		Sum(Case When Datepart(Month,f.fecha_hora) = 7  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Julio,
		Sum(Case When Datepart(Month,f.fecha_hora) = 8  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Agosto,
		Sum(Case When Datepart(Month,f.fecha_hora) = 9  And Datepart(Year,f.fecha_hora) >= @año - 3  Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Septiembre,
		Sum(Case When Datepart(Month,f.fecha_hora) = 10  And Datepart(Year,f.fecha_hora) >= @año - 3 Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Octubre,
		Sum(Case When Datepart(Month,f.fecha_hora) = 11  And Datepart(Year,f.fecha_hora) >= @año - 3 Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Noviembre,
		Sum(Case When Datepart(Month,f.fecha_hora) = 12  And Datepart(Year,f.fecha_hora) >= @año - 3 Then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end Else 0 End) As Diciembre,
		Sum(Case When Datepart(Year,f.fecha_hora) >= @año - 3 then Case When fl.cantidad < 0 then fl.precio_total_local * -1 else fl.precio_total_local end else 0 End) As Total
From pmp.audit_trans_inv f
Inner Join pmp.transaccion_inv fl
On f.audit_trans_inv = fl.audit_trans_inv
Inner Join pmp.articulo a
On fl.articulo = a.articulo
INNER JOIN PMP.CLASIFICACION CC3
ON A.CLASIFICACION_3 = CC3.CLASIFICACION
INNER JOIN PMP.CLASIFICACION CC
ON A.CLASIFICACION_4 = CC.CLASIFICACION
Where Datepart(Year,f.fecha_hora) >= @año - 3
And   Datepart(Year,f.fecha_hora) <= @año
And fl.ajuste_config in('~VV~','RENV')
And (fl.naturaleza = 'E' or fl.naturaleza = 'S')
--AND A.ARTICULO = '001-1000'
And (a.clasificacion_1 IN('ENEM','ACCE','PUBL','COMP')
OR (a.clasificacion_1 in ('TERM','PTR') And a.clasificacion_4 In ('MYCO','RESA','TKAR','TTEX','LAE','BARN','PGTX','PGVI','WTEX','ROXI','BAR')))
Group by cc.Descripcion, Datepart(Year,f.fecha_hora)
Order By cc.Descripcion, Datepart(Year,f.fecha_hora) Desc
 
select * from VentasFamiliaPrecioACCO
Order By Desc_Familia, año Desc

ya que en esto se puede ver que se hacen alias a diferentes tablas y se realiza un sum conteniendo un when anidados

¿Será posible hacerlo en PowerBuilder?... yo manejo el PB 11.5

Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 37
Ha mantenido su posición en Power Builder (en relación al último mes)
Gráfica de Power Builder

Se puede hacer esto en PB?

Publicado por JeinnerH (646 intervenciones) el 13/03/2014 14:46:30
Me parece a golpe de vista que la consulta es posible efectuarla en PB, tal y como está.

Así que no comprendo bien la consulta.

Si consultas sólo si es posible hacerlo en PB. SÍ.

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar