如何将此sql查询转换为Sequelize?
从站中选择a.id,a.name,max(b.sentAt)作为sendAt作为内部连接Monitoring_data_info作为a.id = b.stationId组上的b,按a.id,a.name < / strong>
我尝试了以下代码,但无法运行:
static findStationInfo (){
return this.findAll({
attributes : ['id', 'name', [Sequelize.fn('max', Sequelize.col('sentAt')), 'sentAt']],
include: [{model: MonitoringDataInfo, attributes : [], required: true}],
group: ['Station.id', 'Station.name']
})
}