title: SQL to Sequelize with nested select
body: <p>Need to write the following SQL Query in Sequelize Node js</p>
  <pre><code>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;
  </code></pre>
  <p>This is what I've come up with. I cannot figure out where to put the condition <code>where cnt = 2 and brn = crn;</code></p>
  <pre><code>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]},
          }
      })
  </code></pre>