Commit a47462c2 authored by Anne Blankert's avatar Anne Blankert

allways include nulls in values array

parent 73533621
const sqlTableName = require('./utils/sqltablename.js'); const sqlTableName = require('./utils/sqltablename.js');
// get top 100 most frequent values and null values
const sql = (params, query) => { const sql = (params, query) => {
return ` return `
select count(1)::integer as "count", "${params.column}" as "value" with sortedrecords as
from ${sqlTableName(params.table)} (select count(1)::integer as "count", "${params.column}" as "value"
where ${query.geom_column} is not null from ${sqlTableName(params.table)}
group by "${params.column}" order by count(1) desc limit 100; where ${query.geom_column} is not null
` group by "${params.column}" order by count(1) desc)
,toprecords as
(select * from sortedrecords limit 100)
,resultset as
(select * from toprecords
union
select * from sortedrecords where value is null)
select distinct * from resultset order by count desc;`
} // TODO, use sql place holders $1, $2 etc. instead of inserting user-parameters into query } // TODO, use sql place holders $1, $2 etc. instead of inserting user-parameters into query
// https://leafo.net/guides/postgresql-calculating-percentile.html // https://leafo.net/guides/postgresql-calculating-percentile.html
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment