sql查询集锦(一)

1.求表中3月份薪水增加的用户id。

userId       month       salary     
        1                2000            2

        1                3000            3

        1                4000            4

        2                2000            2

        2                2000            3

        2                2000            4

sql:select * from salary s1 left join salary s2 

on s1.`month` + 1 = s2.`month`  

where s1.month = 2 and s1.userid = s2.userid and s1.salary < s2.salary;

猜你喜欢

转载自blog.csdn.net/sanbingyutuoniao123/article/details/77658040