Nettuts+ Quiz #11: Do You Know SQL?

Nettuts+ Quiz #11: Do You Know SQL?

This entry is part 11 of 12 in the The Official Nettuts+ Quizzes Session
« PreviousNext »

In 2012, we plan to take our quizzes to a whole new level with ones aimed at all languages and catering to all competencies and tastes. This month, we’re covering a little SQL.

With more frameworks being bundled with an ORM, SQL is quickly becoming a lost art and is mostly relegated to the nerdiest of our clan — those pesky database people. Why not take today’s quiz and see whether you DB-chops have really gone the way of the dodo?



Siddharth is Siddharth on Codecanyon
Tags: quizsql
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.istudio.com.mx Alfredo Ramirez

    Yup!! I think it’s time to go back to the classroom!! Consider other languages please!!

  • Mauro

    92.86%, I think the 9th question is kinda vague, but it’s ok.

  • oMiD

    good questions but not expert, tnx

  • Enrico Hernandez

    Question 9 is wrong, you can use where with aggregate functions:

    select count(*) from wp_comments where comment_approved = 1;

    Enrico.

    • Mikaelb

      +1

    • http://bjornline.info bjornredemption

      +1
      ( i hope you didn’t write any SQL for my bank )

    • Richard Cochrane

      +1. It’s even possible with non-aggregate fields, e.g.
      select user, count(1) from user where is_active group by user

      • Rob

        No, that is incorrect the questions is posed for this scenario:

        SELECT * FROM account WHERE count(user)=1

        You cannot do that, that is what its saying when it says WHERE with an aggregate function, If you did need to use an aggregate function you can do so with the HAVING keyword

    • Gabriel Reiser

      +1

      This should be fixed as it’s totally wrong… You CAN use them..

      • http://www.ssiddharth.com Siddharth
        Author

        The question was updated within the first 10 minutes of this quiz going up since the question was being massively misinterpreted. :)

        I’ll check to see if the earlier version is still being served from the cache.

  • http://www.tresorparisuk.com Tresor Paris

    Thanks for sharing this with us.
    Just keep it up.

  • Doug

    I agree with Mauro and Enrico. #9 is wrong. The statement is false.

    I use where clauses all the time with aggregate functions.

    For example, I just ran this on MS’s “pubs” sample database:

    select MAX(discount) from dbo.discounts where discount < 10.5

    and it worked just fine (returned answer of 6.70)

  • lock2007

    85.71% not bad !
    thanks for the quiz

  • http://victorrueda.com.ve Victor

    crap!! going back to the books to go over SQL. I have to say the app used for the Quiz is too freaking AWESOME!! way to go.

    yai, got number 9 right.

  • Steve

    i think #9 aims to something like that

    select …, sum(cost) from … having sum(cost) > 10

    and not

    select …, sum(cost) from … where cost > 10

    got 100% :)

  • http://sarvamantra.com Raman

    Good question but not to right time to learn these . timing problem

  • http://vicious.tk Vicious

    damn it, (How many types of JOINs does the ANSI standard specify?)
    i didn’t read it carefully
    i could have got a perfect score :)

  • Mário Almeida

    100%!!! Woohoo!!!! :-P

  • http://www.yannlorber.fr yann

    never heard of DDL, DML and DCL before :)

  • http://www.tavanir.org.ir/amar/ Omid

    it is simply quiz

    71,43% !!!!!!! NOT Bad :)

  • http://www.surfacehacking.com Jeba

    Almost there! With a little more work, you will have this man’s swagger! You scored 85.71%

    :)

  • Marius

    It says WHERE with an aggregate function, not SELECT. For example

    You can’t use:
    SELECT * FROM salaries
    WHERE SUM(salary) > 10000

    You need to use:

    SELECT * FROM salaries
    GROUP BY salary
    HAVING SUM(salary) > 10000

  • Darius

    The WHERE clause can not be used in conjunction with aggregate functions. Is this statement true or false?

    There is no function SUM_WHERE or something like that. I needed this. We can use where later,

    SELECT SUM(ID) FROM table
    WHERE id > 50

    This will work.

    But how will work:

    SELECT SUM(ID) AS more_50, SUM(ID) AS more_40
    FROM table
    WHERE id > 50

  • Darius

    The WHERE clause can not be used in conjunction with aggregate functions. Is this statement true or false?

    There is no function SUM_WHERE or something like that. I needed this. We can use where later,

    SELECT SUM(ID) FROM table
    WHERE id > 50

    This will work.

    But how will work:

    SELECT SUM(ID) AS more_50, SUM(ID) AS more_40
    FROM table
    WHERE id > 50

    This will still take the ids where more than 50, but I need more than 40. So I answered this question that we cannot use agg functions with where. Its partially true and partially false.

    Only solution I know to get sums of both more_50 and more_40 is to use CASE statement.

  • Darius

    But I think this test is for real begginners. Would be interested in more advanced test which would test knowledge which could be used in real world still, I mean not some stuff which is never practically used.

  • Majid

    great

  • C#Girl

    92.86%

    /*The comment question confused me:))
    Just 13/14 */

  • mohamed mubeen

    I got 71.43%

  • http://www.facebook.com/people/Landon-Sanders/658858097 Landon Sanders

    71.43