software:virtuemart:scripts

СКРИПТЫ полезные и не очень

-- Выборка реквизитов пользователей
SELECT
 CONCAT(b.last_name,' ',b.first_name,' ',b.middle_name) "FIO",
 a.username "Login",
 b.address_1 "Address", 
 CONCAT(b.phone_1,', ',b.phone_2) "Phones",
 b.user_email "EMail",
 b.city "City",
 b.zip "Index",
 c.state_name "Region"
FROM
 `3kota`.`jos_users` a,
 `3kota`.`jos_vm_user_info` b,
 `3kota`.`jos_vm_state` c
-- `3kota`.`jos_vm_country` d
-- `3kota`.`jos_vm_orders` 
WHERE
 a.id = b.user_id AND
 (b.country = 'RUS' AND b.state = c.state_2_code AND c.country_id = '176')
ORDER BY FIO;
-- Выборка статистики по заказам пользователей
-- ФИО, Сумма заказа
SELECT 
 CONCAT(b.last_name,' ',b.first_name,' ',b.middle_name) "FIO",
 a.order_subtotal
FROM
 `3kota`.`jos_vm_orders` a,
 `3kota`.`jos_vm_user_info` b
WHERE
 a.user_id = b.user_id
ORDER BY FIO LIMIT 1000;
-- Выборка по заказам пользователей ИТОГО
-- ФИО, Итого по сумме, кол-во заказов
SELECT 
 CONCAT(b.last_name,' ',b.first_name,' ',b.middle_name) "FIO",
 SUM(a.order_subtotal) "Total",
 COUNT(*) "Orders_NUM"
FROM
 `3kota`.`jos_vm_orders` a,
 `3kota`.`jos_vm_user_info` b
WHERE
 a.user_id = b.user_id
GROUP BY FIO ORDER BY Total DESC;
-- Выборка по заказам пользователей
-- Рекордсмены одиночного заказа
-- ФИО, Итого по сумме, кол-во заказов
SELECT 
 CONCAT(b.last_name,' ',b.first_name,' ',b.middle_name) "FIO",
 SUM(a.order_subtotal) "Total",
 COUNT(*) "Orders_NUM"
FROM
 `3kota`.`jos_vm_orders` a,
 `3kota`.`jos_vm_user_info` b
WHERE
 a.user_id = b.user_id 
GROUP BY FIO ORDER BY Orders_NUM ASC, Total DESC;
SELECT user_id, last_name, first_name, middle_name, phone_1, phone_2, 
       address_1, city, zip, user_email 
FROM jos_vm_user_info 
WHERE city LIKE '%раснояр%' OR zip LIKE '660%'
  • software/virtuemart/scripts.txt
  • Последнее изменение: 2017/05/09 18:34
  • 127.0.0.1