Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.95 KB | None | 0 0
  1. SELECT    ca.card_code,
  2.           b.org_id_from,
  3.           Count(b.id)           AS count_buy,
  4.           Max(b.date)           AS last_date,
  5.           Sum(b.discount_price) AS all_price,
  6.           u.NAME                AS name,
  7.           u.last_name           AS surname,
  8.           ca.user_id,
  9.           Sum(b.org_bonus)      AS bonus,
  10.           Sum(b.org_bonus_down) AS bonus_down,
  11.           Sum(b.POINTS_DOWN)    AS POINTS_DOWN,
  12.           cb.bonus              AS card_bonus,
  13.           uts.uf_yamap_x        AS map_x,
  14.           uts.uf_yamap_y        AS map_y
  15. FROM      b_org_buy_list b
  16. LEFT JOIN b_user_cards ca
  17. ON        ca.ID = b.card_id
  18. LEFT JOIN b_uts_user uts
  19. ON        uts.uf_card_code = ca.card_code
  20. LEFT JOIN b_user u
  21. ON        u.id = uts.value_id
  22. LEFT JOIN b_card_bonus cb
  23. ON        cb.card_id = ca.ID
  24. AND       cb.org_id='137'
  25. WHERE b.ORG_ID ='137'
  26. GROUP BY  b.card_id  
  27. ORDER BY  last_date desc limit 10 offset 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement