美文网首页
sqlzoo(三)SELECT from Nobel Tutor

sqlzoo(三)SELECT from Nobel Tutor

作者: 刘小小gogo | 来源:发表于2021-03-22 14:54 被阅读0次

    12 Find all details of the prize won by EUGENE O'NEIL
    单引号:
    You can't put a single quote in a quote string directly. You can use two single quotes within a quoted string.

    select * from nobel where winner = 'EUGENE O''NEILL'
    

    13 Knights in order

    List the winners, year and subject where the winner starts with Sir. Show the the most recent first, then by name order

    select winner, yr, subject from nobel where winner like 'Sir%' order by yr desc,winner
    

    14
    The expression subject IN ('Chemistry','Physics') can be used as a value - it will be 0 or 1.

    Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.
    按网上的答案 in处一直报错,修改如下,但并没有显示正确

    select winner, subject  from nobel
    where yr=1984
    order by case when  subject IN ('Chemistry','Physics') then 1 else 0 end, subject ,winner 
    

    相关文章

      网友评论

          本文标题:sqlzoo(三)SELECT from Nobel Tutor

          本文链接:https://www.haomeiwen.com/subject/fwalnktx.html