Advertisement
slovacus

query agente

Sep 14th, 2012
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.52 KB | None | 0 0
  1. SELECT
  2.     pty.id
  3.     ,i.id as pav_aviso_id
  4.     ,'1' as aviso_impreso
  5.     ,'0' as aviso_impreso_talan
  6.     ,dpa.contrato as cod_contrato
  7.     ,i.titulo_aviso AS distrito_desc_abr,
  8.     i.Texto_Aviso AS descrip_impreso,
  9.     CASE (IF(pty.uid > 0, 21, pty.parent))
  10.         WHEN 3 THEN IF(pty.type = 1, '101', '109')
  11.         WHEN 5 THEN IF(pty.type = 1, '102', '110')
  12.         WHEN 14 THEN IF(pty.type = 1, '1031', '1111')
  13.         WHEN 4 THEN IF(pty.type = 1, '103', '111')
  14.         WHEN 1 THEN IF(pty.type = 1, '104', '112')
  15.         WHEN 21 THEN '116'
  16.         WHEN 6 THEN '113'
  17.     END AS seccion_diario,
  18.     IF(t.tipo_pago = 2,
  19.         t.token,
  20.         t.id + 87000000) AS token_pago,
  21.     CASE (t.tipo_pago)
  22.         WHEN 0 THEN 'Visa'
  23.         WHEN 1 THEN 'Mastercard'
  24.         WHEN 2 THEN 'PagoEfectivo'
  25.     END AS tipo_pago,
  26.     dpa.precio,
  27.     pty.published,
  28.     pty.name,
  29.     pty.extra32 AS fecha_creacion_aviso,
  30.     t.fecha_modificacion AS fecha_pago,
  31.     i.fecha_publicacion,
  32.     u.name,
  33.     u.apepat,
  34.     u.email,
  35.     t.origen,
  36.     t.tipo_pago AS medio_de_pago,
  37.     t.id AS transac_id,
  38.     pty.image1 AS nombre_fotovineta,
  39.     pty.bedrooms AS num_dormitorios,
  40.     pty.years AS antiguedad,
  41.     pty.area AS area_total,
  42.     pty.covered_area AS area_construida,
  43.     pty.type AS tipo_transac_cod,
  44.     pty.parent AS tipo_inmueble_cod,
  45.     pty.uid,
  46.     lo.Cod_ciudad AS distrito_cod,
  47.     lo.Cod_Departamento AS departamento_cod,
  48.     '0' AS tiene_fotovineta,
  49.     p.tipo_doc,
  50.     p.nro_doc,
  51.     p.razon_social,
  52.     p.direccion,
  53.     p.tipo_cliente,
  54.     p.estado,
  55.     e.ente_code,
  56.     e.Cod_Direccion,
  57.     pty.extra1,
  58.     pty.srb_deportiva,
  59.     pty.srb_vista,
  60.     pty.extra16,
  61.     pty.price as precio_inmueble,
  62.     dpa.tb_paquetes_agente_id as paquete_cod
  63.     ,0 as aviso_bonificado
  64.     ,0 as negrita
  65.     ,0 as encabezado
  66. FROM
  67.     tb_products_impreso i
  68.         INNER JOIN
  69.     tb_detalle_paquete_agente dpa ON i.tb_detalle_paquete_agente_id = dpa.id
  70.         INNER JOIN
  71.     tb_properties_products pty ON pty.id = i.tb_properties_products_id
  72.         INNER JOIN
  73.     tb_properties_locality lo ON pty.lid = lo.id
  74.         INNER JOIN
  75.     tb_transaccion t ON t.tb_detalle_paquete_id = dpa.id
  76.         LEFT JOIN
  77.     tb_perfil_pago p ON p.id = t.tb_perfil_pago_id
  78.         LEFT JOIN
  79.     tb_users u ON u.id = p.tb_users_id
  80.         LEFT JOIN
  81.     tb_perfil_pago_ente e ON p.ente_id = e.ente_code
  82. WHERE
  83.     i.fecha_publicacion = ?
  84.     AND t.procesado = 1 AND
  85.     i.estado = 0 AND t.origen = 3
  86.     AND i.paq_agente = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement