title: Sequelize: group by while including extra attributes on same model
body: <p>I'm new-ish to sequelize (and dev as a whole), but getting along.</p>
  
  <p>I'm trying to make a query in a messaging chat app that can pull all recent conversation threads (1 message from each), done like this in sequelize:</p>
  
  <pre><code>const messages = await db.Message.findAll({
    group: ['userId'],
    attributes: ['userId', [db.sequelize.fn('MAX', db.sequelize.col('createdAt')), 'lastMessageTime']],
    order: [[db.sequelize.fn('MAX', db.sequelize.col('createdAt')), 'DESC']],
    limit: 30,
  </code></pre>
  
  <p>This does group the latest messages properly, but I want to include an extra attribute alongside them, such as the id of the sender. But if I add that in attributes I get this error:</p>
  
  <p>Error: GraphQL error: column "message.senderId" must appear in the GROUP BY clause or be used in an aggregate function</p>
  
  <p>I've been reading about how to include associated models, but I can't seem to include the same model itself. Does anyone have any suggestions or ideas about this?</p>
  
  <p>Thank you very much!</p>