如何在节点sequalize.js中的FROM SQL中执行子查询 我正在使用节点sequalize.js和postgres SQL。 例如:
SELECT
name,
string_agg(date_start::text,' / ') as date_start,
string_agg(date_end::text,' / ') as date_end,
string_agg(sem_range::text,' / ') as sem_range
FROM(
SELECT
name,
sem,
date_start,
days,
date_end
[sequelize.literal("CASE WHEN sem = 'S1' THEN date_start - days ELSE NULL END"), 'sem_start'],
[sequelize.literal("CASE WHEN sem = 'S1' THEN date_end - days ELSE NULL END"), 'sem_end'],
[sequelize.literal("CASE WHEN sem = 'S1' THEN to_char(date_start - days,'YYYY/MM/DD') || ' - ' || to_char(date_end - days,'YYYY/MM/DD') ELSE NULL END"), 'sem_range']
FROM semester as semester
GROUP BY sem, date_start, date_end, days) temp
GROUP BY name
答案 0 :(得分:0)
如果你想进行子查询,那么没有直接的方法,但你可以抛出这个链接。 Is it possible to do a subquery with Sequelize.js? 希望这会有所帮助