Skip to content

Instantly share code, notes, and snippets.

@flee2free
Last active April 10, 2021 14:05
Show Gist options
  • Save flee2free/61acdb98aa0fe7e41060b8f1ebcad6e4 to your computer and use it in GitHub Desktop.
Save flee2free/61acdb98aa0fe7e41060b8f1ebcad6e4 to your computer and use it in GitHub Desktop.
[ANKI Image File Rename] Extract the image resource, rename preserving the sort order #sql #anki
SELECT json_group_object(
trim(file_name), sequence_id
) AS json_result
FROM (select t2.sfld as file_name, t1.due, row_number() over (order by t1.due) as sequence_id
from cards t1
inner join (
select id, flds, sfld, mid
from notes
) t2
on t1.nid = t2.id
order by t1.due);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment