因为有些 Dailynote 是后补的,所以 Dailynote 文档的创建时间和标题时间(事件发生的真实时间)不一致了,所以进行 SQL 查询时希望按真实时间排序,只好取 Dailynote 标题来排序了,请教一下 SQL 该怎么写来实现按标题排序?
目前的 SQL 代码(社区里 copy 的)是按创建时间排序的,哪位大佬帮改一下。
SELECT * FROM blocks as b0 WHERE ( b0.id IN ( SELECT r1.block_id FROM refs as r1 WHERE r1.def_block_id = '20231114094248-1vds7ex' ) AND ( b0.type = 'h' OR b0.type = 'p' OR b0.type = 't' ) AND b0.parent_id NOT IN ( SELECT b1.id FROM blocks as b1 WHERE b1.type = 'i' ) ) OR ( b0.id IN ( SELECT b2.parent_id FROM blocks as b2 WHERE b2.id IN ( SELECT r2.block_id FROM refs as r2 WHERE r2.def_block_id = '20231114094248-1vds7ex' ) ) AND b0.type = 'i' ) ORDER BY b0.updated DESC;