答案 0 :(得分:2)
您可以使用相关子查询
select * from tablename t1 where salary =
(select max(salary) from tablename t2 where t1.deptname=t2.deptname)
答案 1 :(得分:1)
如果支持您的dbms,请使用窗口功能
select * from
(
select *, row_number() over(partition by department order sal desc) rn
from your_tab
) t where t.rn=1
答案 2 :(得分:0)
const User = require("../db").user;
const LocalStrategy = require("passport-local").Strategy;
module.exports = function(passport) {
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
User.findOne({where:{id:id}})
});
passport.use(new LocalStrategy(
{
passReqToCallback: true // allows us to pass back the entire request to the callback
},
(req, username, password, done) => {
User.findOne({where: { username: username }})
.then((user)=>{
console.log("User found")
})
.catch(()=>{
console.log(err)
})
}
)
);
};