|
21 | 21 | collects the Motorcycle spaces & permits |
22 | 22 |
|
23 | 23 | 22/08/2024 - Create SQL |
| 24 | + 11/02/2025 - add totals for following permit types |
| 25 | + permit_type, All Zone, Doctor, Dispensation, Health and Social Care |
| 26 | + Leisure centre permit, Community Support Permit |
24 | 27 | *********************************************************************************/ |
25 | 28 | With parking_permit_denormalised_data as ( |
26 | 29 | SELECT * |
27 | | - from "dataplatform-stg-liberator-refined-zone".parking_permit_denormalised_data |
| 30 | + from "dataplatform-prod-liberator-refined-zone".parking_permit_denormalised_data |
28 | 31 | where import_date = format_datetime(current_date, 'yyyyMMdd') |
29 | 32 | ), |
30 | 33 | LLPG as ( |
31 | 34 | SELECT * |
32 | | - FROM "dataplatform-stg-liberator-raw-zone".liberator_permit_llpg |
| 35 | + FROM "dataplatform-prod-liberator-raw-zone".liberator_permit_llpg |
33 | 36 | WHERE import_date = format_datetime(current_date, 'yyyyMMdd') |
34 | 37 | ), |
35 | 38 | Street_Rec as ( |
36 | 39 | SELECT * |
37 | | - FROM "dataplatform-stg-liberator-raw-zone".liberator_permit_llpg |
| 40 | + FROM "dataplatform-prod-liberator-raw-zone".liberator_permit_llpg |
38 | 41 | WHERE import_date = format_datetime(current_date, 'yyyyMMdd') |
39 | 42 | AND address1 = 'STREET RECORD' |
40 | 43 | ), |
|
79 | 82 | END As Zone |
80 | 83 | FROM "parking-raw-zone".geolive_parking_order as A |
81 | 84 | WHERE import_date = (Select MAX(import_date) from "parking-raw-zone".geolive_parking_order) |
82 | | - AND schedule = 'MC.001' |
| 85 | + AND schedule IN ('MC.001', 'MCC - F') |
83 | 86 | AND street_name is not NULL |
84 | 87 | ), |
85 | 88 | /** Summerise the Parkmap records **/ |
|
154 | 157 | /*** get the VRM details to obtain the m/c flag ***/ |
155 | 158 | MC_Permit_Flag as ( |
156 | 159 | SELECT * |
157 | | - from "dataplatform-stg-liberator-raw-zone".liberator_permit_vrm_480 |
| 160 | + from "dataplatform-prod-liberator-raw-zone".liberator_permit_vrm_480 |
158 | 161 | WHERE import_date = format_datetime(current_date, 'yyyyMMdd') |
159 | 162 | ), |
160 | 163 | /** Get the Permits records link in the LLPG data **/ |
|
187 | 190 | AND A.VRM = D.vrm |
188 | 191 | WHERE A.import_date = format_datetime(current_date, 'yyyyMMdd') |
189 | 192 | AND current_date between start_date and end_date |
190 | | - AND Permit_type IN ( |
191 | | - 'Business', |
192 | | - 'Residents', |
193 | | - 'Companion Badge', |
194 | | - 'Estate Resident' |
195 | | - ) |
| 193 | + AND Permit_type not IN ('Suspension') |
196 | 194 | AND latest_permit_status not IN ('Cancelled', 'Rejected', 'RENEW_REJECTED') |
197 | 195 | ), |
198 | 196 | Permits_summ as ( |
|
246 | 244 | D.currentPermitTotal as Total_Business_Permits, |
247 | 245 | E.currentPermitTotal as Total_Companion_Badge_Permits, |
248 | 246 | L.currentPermitTotal as Total_Motorcycle_Permits, |
| 247 | + |
| 248 | + /*** 11/02/2025 - Add other permits ***/ |
| 249 | + N.currentPermitTotal as Total_Other_Permits, |
| 250 | + |
249 | 251 | /****/ |
250 | 252 | F.no_of_spaces as Business_bay_no_of_spaces, |
251 | 253 | G.no_of_spaces as Shared_Use_no_of_spaces, |
|
256 | 258 | M.no_of_spaces as Motorcycle_bay_no_of_spaces, |
257 | 259 | /****/ |
258 | 260 | ( |
259 | | - coalesce(B.currentPermitTotal, 0) + coalesce(C.currentPermitTotal, 0) + coalesce(D.currentPermitTotal, 0) + coalesce(E.currentPermitTotal, 0) + coalesce(L.currentPermitTotal, 0) |
| 261 | + coalesce(B.currentPermitTotal, 0) + coalesce(C.currentPermitTotal, 0) + coalesce(D.currentPermitTotal, 0) + |
| 262 | + coalesce(E.currentPermitTotal, 0) + coalesce(L.currentPermitTotal, 0)+ coalesce(N.currentPermitTotal, 0) |
260 | 263 | ) as TotalNoofPermits, |
261 | 264 | ( |
262 | | - coalesce(F.no_of_spaces, 0) + coalesce(G.no_of_spaces, 0) + coalesce(H.no_of_spaces, 0) + coalesce(I.no_of_spaces, 0) + coalesce(J.no_of_spaces, 0) + coalesce(K.no_of_spaces, 0) + coalesce(M.no_of_spaces, 0) |
| 265 | + coalesce(F.no_of_spaces, 0) + coalesce(G.no_of_spaces, 0) + coalesce(H.no_of_spaces, 0) + |
| 266 | + coalesce(I.no_of_spaces, 0) + coalesce(J.no_of_spaces, 0) + coalesce(K.no_of_spaces, 0) + coalesce(M.no_of_spaces, 0) |
263 | 267 | ) as TotalNoOfSpaces |
264 | 268 | FROM CPZ_List_DeDupe as A |
265 | 269 | LEFT JOIN Permits_summ as B ON A.cpz = B.cpz |
|
274 | 278 | LEFT JOIN Permits_summ as E ON A.cpz = E.cpz |
275 | 279 | AND lower(A.Street) = lower(E.Street) |
276 | 280 | AND E.permit_type = 'Companion Badge' |
| 281 | +
|
| 282 | + /*** 11/02/2025 add the 'other' permits***/ |
| 283 | + LEFT JOIN Permits_summ as N ON A.cpz = N.cpz |
| 284 | + AND lower(A.Street) = lower(N.Street) AND |
| 285 | + N.permit_type IN ('All Zone','Dispensation','Health and Social Care', |
| 286 | + 'Leisure centre permit','Community Support Permit') |
277 | 287 | /*****/ |
278 | 288 | LEFT JOIN Parkmap_Summary as F ON A.cpz = F.zone |
279 | 289 | AND lower(A.Street) = lower(F.street_name) |
|
316 | 326 | FROM Output |
317 | 327 | WHERE length(trim(cpz)) != 0 |
318 | 328 | AND length(trim(Street)) != 0 |
| 329 | +; |
319 | 330 | """ |
320 | 331 |
|
321 | 332 | create_update_table_with_partition( |
|
0 commit comments