126 | | select p.ime as predmet, count(zz.id_ucenik) as broj_na_zainteresirani_ucenici |
127 | | from predmeti p |
128 | | join zainteresiran_za zz |
129 | | on zz.id_predmet = p.id_predmet |
130 | | join ucenici u |
131 | | on u.id_ucenik = zz.id_ucenik |
132 | | where zz.datum between current_date - interval '100 days' and current_date |
133 | | group by p.ime |
134 | | order by count(zz.id_ucenik) desc |
135 | | limit 1; |
| 126 | select e2."name", q4.max_broj_zainteresirani |
| 127 | from |
| 128 | ((select e.id_event, count(u.id_user) as broj_na_zainteresirani_kupuvaci |
| 129 | from ticket t |
| 130 | join events e |
| 131 | on t.id_event = e.id_event |
| 132 | join users u |
| 133 | on t.id_user_customer =u.id_user |
| 134 | join cart c on c.id_user_customer =t.id_user_customer |
| 135 | where e."date" between current_date - interval '100 days' and current_date |
| 136 | group by e.id_event ) q1 |
| 137 | |
| 138 | join |
| 139 | |
| 140 | ( |
| 141 | select max(q2.broj_na_zainteresirani_kupuvaci) as max_broj_zainteresirani |
| 142 | from ( |
| 143 | select e.id_event, count(u.id_user) as broj_na_zainteresirani_kupuvaci |
| 144 | from ticket t |
| 145 | join events e |
| 146 | on t.id_event = e.id_event |
| 147 | join users u |
| 148 | on t.id_user_customer =u.id_user |
| 149 | join cart c on c.id_user_customer =t.id_user_customer |
| 150 | where e."date" between current_date - interval '100 days' and current_date |
| 151 | group by e.id_event |
| 152 | ) q2 |
| 153 | ) q3 on q1.broj_na_zainteresirani_kupuvaci=q3.max_broj_zainteresirani) |
| 154 | as q4 |
| 155 | join |
| 156 | events e2 |
| 157 | on q4.id_event=e2.id_event |
| 158 | |