Problem solve Get help with specific problems with your technologies, process and projects.

Two SQL homework questions

In a SQL statement, what is the SELECT clause is used to select? What about the FROM clause?

I'm trying to answer the following questions for a homework assignment. Can you help?

  1. In a SQL statement, the SELECT clause is used to select
     (a) columns
     (b) rows
     (c) tables
     (d) none of the above

  2. In a SQL statement the FROM clause is used to select
     (a) which rows to extract from the table
     (b) which tables to extract data from
     (c) which conditions must be met to choose data to extract
     (d) b and c

The answers were not in any of my material. So it's possible that I'm supposed to go outside for answers. Thank you very much.

Your honesty in identifying these as homework questions is appreciated. Students who try to disguise their questions invariably receive no reply at all from me. However, you are really stretching the bounds of credibility in your closing paragraph. The answers to those questions are in your material, assuming that your material is even the most basic of SQL tutorials, and not a fennel soup recipe.

For the first question, consider the following query:

select char(34,72,101,108,108,111
        as message

Is this a column? In the strictest sense, yes. But notice that it is not a column in any table. In fact, there is no table in the query, is there. Still, (a) sounds right.

But what about this query:

select sum(case when gender = 'F'
                then salary * 0.15
       as total_raise_amount
  from employees

Is this SELECT clause not selecting rows? Most definitely, eh. So, (b) sounds right.

Then there's this query:

select * from customer_orders

If that's not selecting an entire table, then what's it doing? Thus, (c) sounds right.

So for the first question, (a), (b), and (c) all sound right, which makes (d) wrong. Does that help?

For the second question, similar examples can be given. The FROM clause selects all rows from the table, which makes (a) correct. It definitely identifies which tables to extract data from, which makes (b) correct. And the FROM clause can also have join conditions (using the ON keyword), so that makes (c) correct. Therefore (d) is also correct. Does that help?

Dig Deeper on Oracle and SQL

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.