by szaboat on 1/30/20, 12:15 PM with 43 comments
by lancefisher on 1/30/20, 4:14 PM
by jolmg on 1/30/20, 4:14 PM
WHERE
country = 'UAE'
AND day >= DATE('2019-07-01')
AND DAY_OF_WEEK(day) != 5
AND scheduled_accuracy_meters <= 10*1000
It looks better when you use a tab-width of 2: WHERE country = 'UAE'
AND day >= DATE('2019-07-01')
AND DAY_OF_WEEK(day) != 5
AND scheduled_accuracy_meters <= 10*1000
by dchess on 1/30/20, 7:21 PM
How is this:
FROM
tablename t
INNER JOIN
other_table ot
ON
t.id = ot.id
More readable than: FROM tablename t
INNER JOIN other_table ot
ON t.id = ot.id
I agree with a lot of these recommendations, but this one irks me. Also I'd love if someone could create a nice code-formatter for SQL like Python's Black.by monkeycantype on 1/31/20, 12:34 AM
select 'biscuit'
where
(
(
@alpha
<
pow(
sin(
radians(
@scheduled_lat - @actual_lat
)
/ 2
)
, 2
)
)
and
@alpha > 0
)
by flatfilefan on 1/30/20, 3:45 PM
by truculent on 1/31/20, 9:06 AM
by whynotmaybe on 1/30/20, 7:53 PM
SELECT
col1
,col2
,col3
It's easier for me to add a column or move it like this.
Otherwise I have to search the comma when my query has only one column and I add one or when I add a column at the endby merusame on 1/31/20, 6:54 AM
by arh68 on 1/30/20, 9:50 PM
My syntax, like others, is a little different (lowercase, 2 spaces, commas-first, bracket quotes, ons right under joins w/ joined table on LHS, left joins left-aligned): (this query isn't supposed to make sense)
select
u.id [user]
, u.email [email]
, o.name [office]
, sum(t.id) [# things]
from main_tblusers_db u
inner join tbloffices_db o
on o.id = u.office_id
inner join things_tbl t
on t.user_id = u.id
left join example e
on e.user_id = u.id
where
u.deleted is null
and (
u.active is not null
or u.special = 1
)
group by
u.id -- the 1, 2 syntax is new to me!
, u.email
, o.name
by leblancfg on 1/30/20, 4:03 PM
P.S. Can I suggest you put your name somewhere in your header?
P.P.S. I see you, too, use 'self' when taking notes. Would you also be a Pythonista? :)
by wodenokoto on 1/30/20, 5:09 PM
by ninju on 1/30/20, 7:22 PM
The author recommends using upper-case for all keywords while Matt Mazur's SQL style guide, that is linked at the bottom of the article, recommends using lowercase for keywords :-)
by vladsanchez on 1/30/20, 5:54 PM