Sometimes you come across a simple SQL statement. Yet you’re confounded by the reasoning behind it. You think, “What is this trying to do?!”
Never had that experience before? Well, here’s your chance. Here’s a heavily anonymised version:
select max(is_active) from customers where customer_id = 'ABC'
And here’s the accompanying database table named “customers”.
|ABC||ABC Pte Ltd||N|
Study both the SQL statement and the data in the database table. Then tell me what you think is the business logic behind the SQL statement.
What I mean is, suppose some manager needs some information. And the SQL statement is part of the solution to obtain that information. What does that manager need to know?
Need some help? Here’s an equivalent version:
select min(customer_status) from customers where customer_id = 'ABC'
|ABC||ABC Pte Ltd||H|
This entire exercise is to train you to decipher existing logic and data with very little help or documentation.
Bonus points: What do you think the values for the columns “is_active” and “customer_status” stand for?