工作中碰到的SQL

(1) sql语句。查询出每个学生自己所学可以中最高分(姓名、科目、学习成绩)

    姓名  科目    学习成绩

    张三   语文    80

    张三   数学    89

     张三   化学    100 

    李四   语文    81

    李四   数学    89

    李四   化学    90

postgresql如下:

select  distinct on(name)  name,course,score from s order by name,score desc 

posted @ 2014-05-06 15:24  焦涛  阅读(147)  评论(0)    收藏  举报