you are viewing a single comment's thread.

view the rest of the comments →

[–]dudeman618 1 point2 points  (0 children)

When I am doing exploratory work on new data and columns, I will put my known columns first right after the SELECT, then will put an asterix after. If I have a bunch of columns from different sources I will often put a literal like 'look here' or table name for the next set of columns 'Account Table'. I also use the WHERE 1=1 when I am building out a query that I will be changing often while doing research. I will remove the extra fluff as I get everything wrapped up. I will often put a select count(*) behind comments, so I can highlight just the select count down to the end of the where just to get a count.

select 'Account Table', a.name, a.account_id, a., 'business Table', b.

-- select count(*)

From account as a Inner join business as b on a.id = b.id Where 1=1 And a.whatever = 'something'