title: Sequelize Include, join, limit associated tables
body: <p>I have a problem with the sequelize query, I think they should give the same rerult, but they don't. Can someone please explain this situation?<br>
  <strong>The first case:</strong><br></p>
  
  <pre><code>getLatestStation = (stationId) =&gt; {
      return models.MonitoringDataInfo.findAll({
        where: {stationId :stationId},
        attributes: ['id', 'stationId', 'sentAt'],
        order : [['sentAt', 'DESC']],
        limit: 1,
        include : [{model: models.MonitoringData, attributes: ['idData', 'indicator', 'value', 'unit', 'sensorStatus']}]
      })
    }
  </code></pre>
  
  <p><br>
  <strong>The first result:</strong><br><a href="https://i.stack.imgur.com/lXnuG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lXnuG.png" alt="enter image description here"></a></p>
  
  <p><br>
  <strong>The first query:</strong>
  <br>
  SELECT [MonitoringDataInfo].*, [MonitoringData].[id] AS [MonitoringData.id], [MonitoringData].[idData] AS [MonitoringData.idData], [MonitoringData].[indicator] AS [MonitoringData.indicator], [MonitoringData].[value] AS [MonitoringData.value], [MonitoringData].[unit] AS [MonitoringData.unit], [MonitoringData].[sensorStatus] AS [MonitoringData.sensorStatus] FROM (SELECT [MonitoringDataInfo].[id], [MonitoringDataInfo].[stationId], [MonitoringDataInfo].[sentAt] FROM [monitoring_data_info] AS [MonitoringDataInfo] WHERE [MonitoringDataInfo].[stationId] = N'mkkneh3uBrAkw9hepMlF' ORDER BY [MonitoringDataInfo].[sentAt] DESC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY) AS [MonitoringDataInfo] LEFT OUTER JOIN [monitoring_data] AS [MonitoringData] ON [MonitoringDataInfo].[id] = [MonitoringData].[idData] ORDER BY [MonitoringDataInfo].[sentAt] DESC;
  <br>
  <br>
  <strong>The second case:</strong><br></p>
  
  <pre><code>getLatestStation = (stationId) =&gt; {
      return models.Station.findAll({
        attributes: ['id', 'name', 'address', 'envIndex'],
        where : {
          id : stationId,
          publicStatus : 1
        },
        include : [{
          model: models.MonitoringDataInfo, 
          limit: 1,
          // where : {
          //   stationId: stationId
          // },
          attributes: ['id', 'stationId', 'sentAt'],
          order : [['sentAt', 'DESC']],
          limit : 1,
          include : [{model: models.MonitoringData, attributes: ['idData', 'indicator', 'value', 'unit', 'sensorStatus']}]
        }]
      })
    } 
  </code></pre>
  
  <p><br>
  <strong>The second result:</strong> <br><a href="https://i.stack.imgur.com/BPDmw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BPDmw.png" alt="enter image description here"></a>
  <br>
  <strong>The second query:</strong>
  SELECT [Station].[id], [Station].[name], [Station].[address], [Station].[envIndex] FROM [stations] AS [Station] WHERE [Station].[id] = N'mkkneh3uBrAkw9hepMlF' AND [Station].[publicStatus] = 1; <br>
  SELECT [MonitoringDataInfo].[id], [MonitoringDataInfo].[stationId], [MonitoringDataInfo].[sentAt], [MonitoringData].[id] AS [MonitoringData.id], [MonitoringData].[idData] AS [MonitoringData.idData], [MonitoringData].[indicator] AS [MonitoringData.indicator], [MonitoringData].[value] AS [MonitoringData.value], [MonitoringData].[unit] AS [MonitoringData.unit], [MonitoringData].[sensorStatus] AS [MonitoringData.sensorStatus] FROM [monitoring_data_info] AS [MonitoringDataInfo] LEFT OUTER JOIN [monitoring_data] AS [MonitoringData] ON [MonitoringDataInfo].[id] = [MonitoringData].[idData] WHERE [MonitoringDataInfo].[stationId] IN (N'mkkneh3uBrAkw9hepMlF') ORDER BY [MonitoringDataInfo].[sentAt] DESC, [MonitoringDataInfo].[id] OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY; </p>