3 ms·
That's a totally valid point haha.
by regexman1 2y ago
That's a totally valid point haha.
- silveraxe93 2y agoI'll try to give some constructive criticism instead of a drive by pot shot. I'm sorry, it's just that the leading commas make my eyes bleed and I really hope the industry moves away from it. On point 3: What I do is use CTEs to create intermediate columns (with good names) and then a final one creating the final column. It's way more readable. ```sql with intermediate as ( select DATEDIFF(DAY, timeslot_date, CURRENT_DATE()) > 7 as days_7_difference, DATEDIFF(DAY, timeslot_date, CURRENT_DATE()) >= 29 as days_29_difference, LAG(overnight_fta_share, 1) OVER (PARTITION BY timeslot_date, timeslot_channel ORDER BY timeslot_activity) as overnight_fta_share_1_lag, LAG(overnight_fta_share, 2) OVER (PARTITION BY timeslot_date, timeslot_channel ORDER BY timeslot_activity)as overnight_fta_share_2_lag from timeslot_data) select iff(days_7_difference, overnight_fta_share_1_lag, null) as C7_fta_share, iff(days_29_difference, overnight_fta_share_2_lag, null) as C28_fta_share from intermediate ```
- regexman1 2y agoI appreciate the feedback, no offence taken. I'm an analyst so I often find the leading comma useful when I'm testing something and want to quickly comment a column out but I take your point. And I agree, I should have used CTEs for this query, I was just trying to save lines of code which had the unintended consequence of quite an ugly query. However I did want to use it as an example of indentation being useful to make it slightly easier to read. Although perhaps I'm the only one who thinks so. I greatly appreciate the constructive criticism.
- password4321 2y ago> testing something and want to quickly comment a column out This is a pretty solid reason for use in temporary queries so no doubt this approach will be around for a long time.
- otteromkram 2y agoI love leading commas and am leading the charge for change. I apologize in advance and hope you are able to come to grips with how easy it is to read and understand at some point in the near future.