• About WordPress
    • WordPress.org
    • Documentation
    • Support
    • Feedback
  • Log In
  • Register
  • Log In
  • Register
Last Mile Dot Earth
  • Groups
  • Members
  • Products
  • Packages
  • blog
  • Hiring 1 Thousand Veterans
    Sign in Sign up
    Last Mile Dot Earth
    Last Mile Dot Earth
    • Groups
    • Members
    • Products
    • Packages
    • blog
    • Hiring 1 Thousand Veterans

    • Log In
    • Register

    Category: career tips

    How to Build a Killer Data Science Portfolio

    Even with the shortage of qualified applicants, the data science job market can be quite competitive. For those trying to land their first data science…

    lastmileearth November 30, 2021

    How to Maximize Your Data Science Salary

    Negotiating salaries is something many people are not comfortable with, but as the data shows, pushing through the discomfort can be incredibly rewarding. If you’re…

    lastmileearth November 25, 2021

    Data Science Podcasts To Start Listening Today

    Data science is a complex field to work in. However, data science podcasts introduce you to thought-provoking problems and stimulating discussions among experts in the…

    lastmileearth November 5, 2021

    Evolution of Data Science: Growth & Innovation

    The term “data science” — and the practice itself — has evolved over the years. In recent years, its popularity has grown considerably due to…

    lastmileearth October 21, 2021

    30-Day Data Science Challenge

    We’re excited to kick off the 30 Day Dataquest Challenge! Here’s why: Building learning habits is crucial to your data career, but it can be…

    lastmileearth September 1, 2021

    Data Analyst Skills – 8 Skills You Need to Get a Job

    What is a Data Analyst? A data analyst is someone who uses technical skills to analyze data and report insights. On a typical day, a…

    lastmileearth April 18, 2021

    Data Engineer, Data Analyst, Data Scientist — What’s the Difference?

    Data engineer, data analyst, and data scientist — these are job titles you’ll often hear mentioned together when people are talking about the fast-growing field…

    lastmileearth April 12, 2021

    You Need Data Skills to Future-Proof Your Career

    No matter what industry you’re in, you need data skills to future-proof your career.  You might be thinking: Vik is the CEO of a company…

    lastmileearth April 5, 2021

    Data Analytics Certification: Do You Need a Certificate to Get a Job as a Data Analyst?

    If you’re interested in becoming a data analyst, or even just interested in adding some data skills to your resume, you’ve probably wondered: do I…

    lastmileearth March 18, 2021

    SQL Interview Questions — Real Questions to Prep for Your Job Interview

    If you’re looking for a job in data, chances are you’re going to have to answer some SQL interview questions, or complete some kind of…

    lastmileearth February 1, 2021
    Load More
    © 2023 - Michael Noel Site

    Forum Description

    sql-interview-questions

    If you're looking for a job in data, chances are you're going to have to answer some SQL interview questions, or complete some kind of SQL test.

    That's because SQL skills are required for most data jobs. We dug into the data in depth in this post about why you should learn SQL, but the short version is this: more than half of all data analyst, data scientist, and data engineer jobs in 2021 list SQL as a requirement.

    The importance of SQL is especially stark for data analyst roles:

    Skills listed in data analyst job posts, SQL is the most in-demand skill

    SQL is far and away the most in-demand skill for Data Analyst roles. Data: Indeed.com, 1/29/2021.

    Preparing for SQL questions in a job interview

    We've written an extensive guide on job interviews in data science. You should be aware that SQL will almost certainly play a role in your interview process, especially if you're looking at Data Analyst roles.

    Every company does things differently, but here are a few of the more common ways companies test SQL skills:

    • In-person (or video) interview where you're asked SQL questions or given SQL problems to solve.
    • Take-home SQL task or tasks.
    • In-person (or video) live coding session where you're asked to use SQL skills to answer questions in real time.
    • Whiteboard coding session where you're asked to demonstrate your SQL skills by sketching out queries on a whiteboard.

    If you're not comfortable writing SQL queries already, there's no time like the present to sign up for a free account and dive into our interactive SQL courses. But let's say you're already a SQL master. You're still going to want some practice!

    And that's where you may encounter a problem.

    Online practice question lists are (mostly) terrible

    If you Google "SQL Interview questions," you're going to find a bunch of articles that list questions like these (these are all real questions pulled from top-ranking articles)

    • What is SQL?
    • What is a database?
    • What are tables?
    • What is a join?

    You get the idea. And we suppose it's possible that you'll be asked "what is SQL" in a job interview. But it's definitely not likely.

    Much more likely: the SQL interview questions you'll face will be asking you to solve real problems with SQL, or asking you to answer trickier questions that test your working knowledge.

    We've compiled some of these questions below, and provided expandable answers so that you can test yourself, and then check to make sure you're right.

    Test yourself with real SQL interview questions:

    Question 1

    Given the table below, write a SQL query that retrieves the personal data about alumni who scored above 16 on their calculus exam.

    alumni

    student_id name surname birth_date faculty
    347 Daniela Lopes 1991-04-26 Medical School
    348 Robert Fischer 1991-03-09 Mathematics

    evaluation

    student_id
    class_id
    exam_date
    grade
    347
    74
    2015-06-19
    16
    347
    87
    2015-06-06
    20
    348
    74
    2015-06-19
    13
    class_id
    class_name
    professor_id
    semester
    74
    algebra
    435
    2015_summer
    87
    calculus
    532
    2015_summer
    46
    statistics
    625
    2015_winter

    Click to reveal answer

    There are several possible answers. Here’s one:

    SELECT a.name, a.surname, a.birth_date, a.faculty FROM alumni AS a INNER JOIN evaluation AS e ON a.student_id=e.student_id INNER JOIN curricula AS c ON e.class_id = c.class_id WHERE c.class_name = 'calculus' AND e.grade>16;

    Question 2

    We’ll work with the beverages table. Its first rows are given below.

    id name launch_year fruit_pct contributed_by
    1 Bruzz 2007 45 Sam Malone
    2 Delightful 2008 41 Sam Malone
    3
    Nice 2015 42
    Sam Malone

    Write a query to extract only beverages where fruit_pct is between 35 and 40 (including both ends).

    Click to reveal answer

    There are several possible answers. Here’s one:

    SELECT * FROM beverages WHERE fruit_pct BETWEEN 35 AND 40;

    Question 3

    We’ll work with the beverages table again. Its first rows are given below.

    id name launch_year fruit_pct contributed_by
    1 Bruzz 2007 45 Sam Malone
    2 Delightful 2008 41 Sam Malone
    3
    Nice 2015 42
    Sam Malone

    Write a query to extract only beverages whose contributor only has one name

    Click to reveal answer

    There are several possible answers. Here’s one:

    SELECT * FROM beverages WHERE contributed_by NOT LIKE '% %';

    Question 4

    We’ll work with the beverages table again. Its first rows are given below.

    id name launch_year fruit_pct contributed_by
    1 Bruzz 2007 45 Sam Malone
    2 Delightful 2008 41 Sam Malone
    3
    Nice 2015 42
    Sam Malone

    Write a query that finds the average fruit_pct by contributor and displays it ascending order.

    Click to reveal answer

    There are several possible answers. Here’s one:

    SELECT contributed_by, AVG(fruit_pct) AS mean_fruit FROM beverages GROUP BY contributed_by ORDER BY mean_fruit;

    Question 5

    Take a look at the query given below:

    SELECT column, AGG_FUNC(column_or_expression), … FROM a_table INNER JOIN some_table ON a_table.column = some_table.column WHERE a_condition GROUP BY column
    HAVING some_condition ORDER BY column LIMIT 5;

    In what order does SQL run the clauses? Select the correct option from the list of choices below:

    1. SELECT, FROM, WHERE, GROUP BY
    2. FROM, WHERE, HAVING, SELECT, LIMIT
    3. SELECT, FROM, INNER JOIN, GROUP BY
    4. FROM, SELECT, LIMIT, WHERE

    Click to reveal answer

    The correct option is 2. It goes like this:

    1. The SQL engine fetches the data from the tables (FROM and INNER JOIN)
    2. Filters it (WHERE)
    3. Aggregates the data (GROUP BY)
    4. Filters the aggregated data (HAVING)
    5. Selects the columns and expressions to display (SELECT)
    6. Orders the remaining data (ORDER BY)
    7. Limits the results (LIMIT)

    Question 6

    What is the purpose of an index in a database table?

    Click to reveal answer

    The purpose of an index in a database table is to improve the speed of looking through that table's data. The standard analogy is that it's (usually) much faster to look up something in a book by looking at its index than by flipping every page until we find what we want.

    Question 7

    What rows of my_table does the following query yield? Give a descriptive answer.

    SELECT * FROM my_table WHERE 1 = 1.0;

    Click to reveal answer

    It returns the whole table because 1=1.0 always evaluates to true.

     

    Question 8

    What rows of my_table does the following query yield? Give a descriptive answer.

    SELECT * FROM my_table WHERE NULL = NULL;

    Click to reveal answer

    It returns no rows because, by definition, NULL does not equal itself.

     

    More resources for SQL interview prep

    We'll be adding new questions to that list over time, but in the interim, here are some more helpful resources for review during your SQL interview question prep:

    Of course, don't forget to bookmark this post, because we'll be adding more SQL interview questions for you to quiz yourself with over time!

    Learn SQL the right way!

    • Writing real queries
    • In your browser
    • On your schedule

    Why passively watch video lectures when  you can learn by doing?

    SQL questions written by Bruno Cunha.

    Last Mile Source

    Report

    There was a problem reporting this post.

    Harassment or bullying behavior
    Contains mature or sensitive content
    Contains misleading or false information
    Contains abusive or derogatory content
    Contains spam, fake content or potential malware

    Block Member?

    Please confirm you want to block this member.

    You will no longer be able to:

    • See blocked member's posts
    • Mention this member in posts
    • Invite this member to groups
    • Message this member
    • Add this member as a connection

    Please note: This action will also remove this member from your connections and send a report to the site admin. Please allow a few minutes for this process to complete.

    Report

    You have already reported this .
    Clear Clear All