Advertisement
slovacus

query data

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