46|SQL – Barry Bee Benson Co

Really good problem here!
From what I could see, he mistakenly used Last Names that start with B in the first one. In the second, he ordered the locations in desc instead of asc. Lastly, did not allow for the name Brian to be returned.
Thanks for the practice!

Fun way to learn how to find and correct mistakes.
Looks like he queried last names instead of first names in the first query. In the second one, he ordered the location by dsc instead of alphabetically. And in the third he didn’t include Brian in the where statement.

For the first solution he had LName in the WHERE Statement
For the Second one he had d.Location as DESC
For the third solution he left “Brian” out of his WHERE Statement

  1. He included LName instead of FName in the WHERE statement.
  2. d.Location is DESC instead of ASC
  3. Brian was not included in the WHERE statement.
  1. Bradford put LName instead of FName in the WHERE statement.
  2. Bradford should sort the data in ascending order by location instead of descending order.
  3. Bradford forgot to search for Brian in the WHERE statement.

In the first query, Bradford put LName instead of FName in the WHERE statement.

In the second query, he sorted the locations in descending order whereas he should have sorted them in ascending order.

Bradford did not put ‘Brian’ in the WHERE statement

1 Like

Error 1: LName in the WHERE
Error 2: Data was in ascending order instead of descending order.
Error 3: No Brian in the WHERE statement.

Tech Hub challenge 46 Solution.docx (12.6 KB)

This was a good way to review SQL, especially with INNER JOIN

Berry put LName in the place of FName in the WHERE statement, which caused the names to be out of order.
The order of the locations was flipped on the second query
In the third query, Barry didn’t include “Brian” in the WHERE statement, so those results weren’t included.

1 Like

Error 1: Barry went wrong in His WHERE statement as he entered LName instead of FName
Error 2: Barry added DESC to his ORDER BY statement instead of ASC so the data was ordered incorrectly
Error 3: Barry forgot to add OR statements to include Brian and Brent

1 Like

Bradfords mistakes in each query were

  1. instead of putting FName in the WHERE field Barry put LName there
  2. instead of ordering by d.Location ASC he ordered it DESC
  3. accidentally forgot to include “Brian” in the WHERE field

After reviewing the queries here are the mistakes I found.
In the first query, Barry must have used LName instead of FName in the WHERE statement.
In the second one, he ordered the data in descending order, and it should have been ASC.
In the third one, Barry simply forgot to list Brian as one of the names in the WHERE statement.

Not quite sure where the incorrect code was, the file didn’t have anything I could find that looked like incorrect queries. The solutions all looked correct. So I played with the solutions to figure out what he did wrong.

  1. He must have used LName in the Where statement instead of FName.
  2. He ordered the locations wrong. Should have been ASC, but he did DESC.
  3. He forgot to include Brian in the where statement which is why he didn’t get enough rows.
1 Like

Bradford’s 1st Query:
His query was wrong because he sorted WHERE by e.LName LIKE “B*” (the L needed to be an F).
Bradford’s 2nd Query:
His query was wrong because in his ORDER BY he followed d.Location with DESC where he should have used ASC or left it blank.
Bradford’s 3rd Query:
His query was wrong because he didn’t include a search for Brian (somewhere after Where he should have also included a search for e.FName LIKE “Brian*”).

Note: I noticed a possible error in the instructions. In the bullet under the 3rd query describing Bradford’s query results it says, “Brent Manion” was the first result, but I believe it should be Bruce Manion. (This was something that tripped me up at first.)

1 Like

In the first solution, he used LName which called the Last name instead of the First name.
In the second solution, he used DESC instead of ASC in the d.location order by
In the last solution, he forgot to include the name Brian

[quote=“Boston, post:1, topic:632”]
Solution Code

Simple solution for sensitive SQL is using the first instead of the last name for the first problem. the order should be flipped. Having count function I believe can be written another way, I tried to use a where statement alone but having is much more concise.

1 Like
  1. For the first problem Bradford used LName instead of the FName in the Where field
  2. This one he sorted the data with Desc instead of ASC
  3. He didn’t include Brian in the Where statement

He shouldn’t have included the LName in the WHERE section
He mixed up how he sorted the data
He didn’t put Brian in the WHERE section

1 Like

Bradford made several mistakes. He used LNAME in the WHERE when it was not necessary. For the second one, it turns out he organized the data inversely. For the last QUERY, he forgot to put Brian in the where statement.

1 Like

Bradford’s Mistakes:
First Query - Bradford used LName instead of FName in the WHERE statement.
Second Query - Bradford sorted the data in Desc instead of ASC
Third Query - Bradford didn’t include Brian in the WHERE statement

1 Like