Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT COUNT(*)
- FROM (
- SELECT mcontent
- FROM (
- SELECT
- (CASE WHEN (ce.content IS NULL OR ce.content = '') THEN cp.content ELSE ce.content END) AS mcontent
- FROM copyright AS cp
- INNER JOIN uploadtree_a AS UT ON cp.pfile_fk = UT.pfile_fk
- LEFT JOIN copyright_event AS ce ON ce.copyright_fk = cp.copyright_pk
- AND ce.upload_fk = $5
- AND ce.uploadtree_fk = UT.uploadtree_pk
- WHERE cp.content != ''
- AND (UT.lft BETWEEN $1 AND $2)
- AND cp.type = $3
- AND cp.agent_fk = ANY($4::int[])
- AND (ce.is_enabled IS NULL OR ce.is_enabled = 'true')
- AND UT.upload_fk = $5
- GROUP BY mcontent
- UNION ALL
- SELECT DISTINCT textfinding AS mcontent
- FROM copyright_decision AS cd
- INNER JOIN pfile AS PF ON cd.pfile_fk = PF.pfile_pk
- INNER JOIN uploadtree_a AS UT ON PF.pfile_pk = UT.pfile_fk
- WHERE UT.lft BETWEEN $1 AND $2
- AND (cd.is_enabled IS NULL OR cd.is_enabled = 'true')
- AND UT.upload_fk = $5
- ) AS combined
- ) AS K;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement