Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT avg(Tmp_1.summ)
- FROM (
- SELECT strftime("%m, %Y", Purchases.DATE) AS MONTH, SUM(Items.price) AS summ
- FROM Users
- INNER JOIN Purchases ON Users.userid = Purchases.userid
- INNER JOIN Items ON Purchases.itemid = Items.itemid
- WHERE (Users.age >= 18) AND (Users.age <= 25)
- GROUP BY MONTH) AS Tmp_1;
- SELECT avg(Tmp_2.summ)
- FROM (
- SELECT strftime("%m, %Y", Purchases.DATE) AS MONTH, SUM(Items.price) AS summ
- FROM Users
- INNER JOIN Purchases ON Users.userid = Purchases.userid
- INNER JOIN Items ON Purchases.itemid = Items.itemid
- WHERE (Users.age >= 26) AND (Users.age <= 35)
- GROUP BY MONTH) AS Tmp_2;
- SELECT avg(Tmp_3.summ)
- FROM (
- SELECT strftime("%m, %Y", Purchases.DATE) AS MONTH, SUM(Items.price) AS summ
- FROM Users
- INNER JOIN Purchases ON Users.userid = Purchases.userid
- INNER JOIN Items ON Purchases.itemid = Items.itemid
- GROUP BY MONTH) AS Tmp_3;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement