Init scrips for postgres.
This commit is contained in:
parent
069ea6962a
commit
f2ef02a033
13
pg/list-ids.sql
Normal file
13
pg/list-ids.sql
Normal file
@ -0,0 +1,13 @@
|
||||
SELECT
|
||||
COUNT(value),
|
||||
SUBSTRING(value from '(.*)<') AS name,
|
||||
COALESCE(SUBSTRING(value from '<(.*)>'), value) AS id
|
||||
FROM
|
||||
header
|
||||
WHERE
|
||||
name = 'List-Id'
|
||||
GROUP BY
|
||||
value
|
||||
ORDER BY
|
||||
count DESC
|
||||
;
|
||||
30
pg/named-list-ids.sql
Normal file
30
pg/named-list-ids.sql
Normal file
@ -0,0 +1,30 @@
|
||||
SELECT
|
||||
DISTINCT ON(
|
||||
LOWER(COALESCE(SUBSTRING(value from '<(.*)>'), value)))
|
||||
COALESCE(named.count, 1),
|
||||
LOWER(COALESCE(named.name,
|
||||
LOWER(COALESCE(SUBSTRING(value from '<(.*)>'), value)))) AS id,
|
||||
unnamed.name AS name
|
||||
FROM
|
||||
header unnamed
|
||||
LEFT OUTER JOIN (
|
||||
SELECT
|
||||
DISTINCT ON (LOWER(COALESCE(SUBSTRING(value from '<(.*)>'), value)))
|
||||
COUNT(value) AS count,
|
||||
SUBSTRING(value from '(.*)<') AS name,
|
||||
LOWER(COALESCE(SUBSTRING(value from '<(.*)>'), value)) AS id
|
||||
FROM
|
||||
header
|
||||
WHERE
|
||||
name != ''
|
||||
GROUP BY
|
||||
LOWER(COALESCE(SUBSTRING(value from '<(.*)>'), value)),
|
||||
SUBSTRING(value from '(.*)<')
|
||||
ORDER BY
|
||||
id,
|
||||
count DESC,
|
||||
name
|
||||
) named
|
||||
ON
|
||||
named.id = LOWER(COALESCE(SUBSTRING(unnamed.value from '<(.*)>'), unnamed.value))
|
||||
;
|
||||
Loading…
x
Reference in New Issue
Block a user