test
Sql
code posted
created at 28 Aug 09:04
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
SELECT User.id ,User.login ,User.password ,City.name ,School.name ,(CASE WHEN User.failed_transactions_count > 0 THEN 1 ELSE 0 END) AS has_failed_transactions, Transaction.amount FROM User JOIN City ON User.city_id = City.id LEFT JOIN School ON User.school_id = School.id LEFT JOIN (SELECT Transaction.user_id ,SUM(Transaction.amount) AS amount FROM Transaction GROUP BY Transaction.user_id ) AS Transaction ON User.id = Transaction.user_id WHERE User.gender = 'M' AND User.active = 1 AND User.user_status_id = 1 ORDER BY User.login |
774 Bytes in 2 ms with coderay