Parašė ozzWANTED· 2009 Lap. 4 18:11:50
#12
Prašom:
WITH LENTELE_PAGAL_KIEKIUS AS
( SELECT
tu.user_id AS id, tu.user_name AS vardas,
COUNT(d.download_url) AS siuntiniu, COUNT(ers.error_summary) AS klaidu, COUNT (a.article_subject) AS straipsniu
FROM ".DB_USERS." tu
LEFT JOIN ".DB_DOWNLOADS." d ON tu.user_id=d.download_license AND download_cat IN(1,2)
LEFT JOIN ".DB_ARTICLES." a ON tu.user_id=a.article_name
LEFT JOIN ".DB_PREFIX."error_reports ers ON tu.user_id=ers.error_user
GROUP BY tu.user_id
ORDER BY user_id)
SELECT id, vardas, (siuntiniu+klaidu+straipsniu) AS viso_kiekio
FROM LENTELE_PAGAL_KIEKIUS
ORDER BY viso_kiekio DESC, id
Redagavo ozzWANTED· 2009 Lap. 4 21:11:33