HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

Query to find users from Australia

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
queryusersaustraliafindfrom

Problem

After a discussion of which users were from Australia, I wrote my first SQL query to find out:

SELECT u.DisplayName'Display Name', u.Reputation'Rep', u.Location'Location'
FROM Users u
WHERE u.Location LIKE '%Australia%'
ORDER BY 'Rep' DESC


As always, please tell me the good, the bad, and the ugly.

The query can be found here

Solution

I don't like how you're specifying the column aliases. I expect a whitespace between the column and the alias.

I like that you're not specifying the optional AS keyword though - I find it only adds clutter when it's there.

Also I would have used [square brackets] instead of single quotes, and layout the field names on separate lines, like this:

SELECT 
     u.DisplayName [Display Name]
    ,u.Reputation [Rep]
    ,u.Location [Location]


That way you can easily add, reorder, or comment-out a column if you need to.

Code Snippets

SELECT 
     u.DisplayName [Display Name]
    ,u.Reputation [Rep]
    ,u.Location [Location]

Context

StackExchange Code Review Q#87044, answer score: 13

Revisions (0)

No revisions yet.