Add create_view_public.latest_document_versions.sql
This commit is contained in:
parent
164ec7897a
commit
a474ba1b74
19
create_view_public.latest_document_versions.sql
Normal file
19
create_view_public.latest_document_versions.sql
Normal file
@ -0,0 +1,19 @@
|
||||
-- View: public.latest_document_versions
|
||||
|
||||
-- DROP VIEW public.latest_document_versions;
|
||||
|
||||
CREATE OR REPLACE VIEW public.latest_document_versions
|
||||
AS
|
||||
SELECT dv.doc_id,
|
||||
dv.content,
|
||||
dv.version_number,
|
||||
dv.updated_at
|
||||
FROM document_versions dv
|
||||
JOIN ( SELECT document_versions.doc_id,
|
||||
max(document_versions.version_number) AS max_version
|
||||
FROM document_versions
|
||||
GROUP BY document_versions.doc_id) latest ON dv.doc_id = latest.doc_id AND dv.version_number = latest.max_version;
|
||||
|
||||
ALTER TABLE public.latest_document_versions
|
||||
OWNER TO dbuser01;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user