需要在 Sequelize Node js 中编写如下 SQL Query
select a, b, c
from (
select tbl.*,
count(*) over(partition by a) cnt,
row_number() over (partition by a order by b) brn,
row_number() over (partition by a order by c) crn
from tbl
where c in (4, 5)
) t
where cnt = 2 and brn = crn;
这就是我想出的。我不知道在哪里放置条件where cnt = 2 and brn = crn;
t.findAll({
attributes: {
include: [
[sequelize.literal('count(*) over(partition by a)'),'cnt'],
[sequelize.literal('row_number() over (partition by a order by b)'),'brn'],
[sequelize.literal('row_number() over (partition by a order by c)'),'crn'],
]
},
where: {
c: {[Op.in]:[4,5]},
}
})