Datasets:
id stringlengths 36 36 | pergunta stringlengths 37 1.4k | sql stringlengths 12 4.57k | dificuldade stringclasses 4
values | categorias listlengths 1 4 | order_matters bool 2
classes | num_column_matters bool 2
classes | num_row_matters bool 2
classes |
|---|---|---|---|---|---|---|---|
environmental_registry_benchmark_001 | Quantos imóveis rurais ativos existem no Mato Grosso do Sul? | SELECT
COUNT(*) AS total_imoveis
FROM
analise_dados.dim_imovel di
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) = de.cod_uf
WHERE
di.ind_tipo_imovel = 'IRU'
AND di.ind_status_imovel = 'AT'
AND de.sigla_uf = 'MS'; | fácil | [
"imovel",
"geografico"
] | false | false | true |
environmental_registry_benchmark_002 | Quantas unidades de conservação estão cadastradas no bioma Pantanal? | SELECT
COUNT(*) AS total_ucs
FROM
analise_dados.dim_unidades_conservacao
WHERE
UPPER(biomaibge) = 'PANTANAL'; | fácil | [
"unidade_conservacao",
"geografico"
] | false | false | true |
environmental_registry_benchmark_003 | Qual a classificação de tamanho mais comum dos imóveis rurais no Rio Grande do Sul? | SELECT
di.class_tam_imovel,
COUNT(*) AS total
FROM
analise_dados.dim_imovel di
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) = de.cod_uf
WHERE
di.ind_tipo_imovel = 'IRU'
AND de.sigla_uf = 'RS'
GROUP BY
di.class_tam_imovel
ORDER BY
total DESC
LIMIT
1; | fácil | [
"imovel",
"geografico"
] | false | false | false |
environmental_registry_benchmark_004 | Quais unidades de conservação de proteção integral existem no bioma Amazônia? | SELECT
uc.nomeuc
-- uc.siglacateg,
-- uc.esferaadm,
-- uc.areahaalb,
-- uc.criacaoano
FROM
analise_dados.dim_unidades_conservacao uc
WHERE
uc.grupouc = 'PI'
AND UPPER(uc.biomaibge) = 'AMAZÔNIA'
ORDER BY
uc.areahaalb DESC; | fácil | [
"unidade_conservacao",
"geografico"
] | false | false | true |
environmental_registry_benchmark_005 | Quais unidades de conservação (código e nome) estão localizadas no bioma Pantanal? | SELECT
cnuc,
nomeuc
FROM
analise_dados.dim_unidades_conservacao
WHERE
UPPER(biomaibge) = 'PANTANAL'; | fácil | [
"unidade_conservacao",
"geografico"
] | false | true | true |
environmental_registry_benchmark_006 | Qual a quantidade de embargos em 2022? | SELECT
COUNT(*) AS total_embargos
FROM dim_embargo
WHERE TO_TIMESTAMP(dat_embarg, 'DD/MM/YY HH24:MI:SS') >= DATE '2022-01-01'
AND TO_TIMESTAMP(dat_embarg, 'DD/MM/YY HH24:MI:SS') < DATE '2023-01-01'; | fácil | [
"terra_indigena",
"geografico"
] | false | false | true |
environmental_registry_benchmark_007 | Qual a soma total da área de todos os imóveis rurais ativos cadastrados no CAR? | SELECT
SUM(di.area_imovel) AS area_total_ha
FROM
analise_dados.dim_imovel di
WHERE
di.ind_tipo_imovel = 'IRU'
AND di.ind_status_imovel = 'AT'; | fácil | [
"imovel"
] | false | false | true |
environmental_registry_benchmark_008 | Qual a área total de unidades de conservação de proteção integral no bioma Amazônia? | SELECT
SUM(duc.areahaalb) AS area_total_ha
FROM
analise_dados.dim_unidades_conservacao duc
WHERE
duc.grupouc = 'PI'
AND duc.biomaibge = 'AMAZÔNIA'; | fácil | [
"unidade_conservacao"
] | false | false | true |
environmental_registry_benchmark_009 | Quantos imóveis rurais não possuem coordenadas de centroide cadastradas? | SELECT
COUNT(*) AS total_sem_coordenadas
FROM
analise_dados.dim_imovel
WHERE
ind_tipo_imovel = 'IRU'
AND (
lat_imovel IS NULL
OR long_imovel IS NULL
); | fácil | [
"imovel",
"qualidade_dados"
] | false | false | true |
environmental_registry_benchmark_010 | Quantas parcelas SIGEF foram submetidas mas ainda não possuem data de aprovação preenchida? | SELECT
COUNT(*) AS parcelas_sem_aprovacao
FROM
analise_dados.dim_sigef
WHERE
data_submissao IS NOT NULL
AND data_aprovacao IS NULL; | fácil | [
"sigef",
"qualidade_dados"
] | false | false | true |
environmental_registry_benchmark_011 | Qual o percentual de imóveis rurais que não possuem módulo fiscal calculado? | SELECT
ROUND(
100.0 * COUNT(*) FILTER (
WHERE
num_modulo_fiscal IS NULL
) / NULLIF(COUNT(*), 0),
2
) AS percentual_sem_modulo
FROM
analise_dados.dim_imovel
WHERE
ind_tipo_imovel = 'IRU'; | fácil | [
"imovel",
"qualidade_dados"
] | false | false | true |
environmental_registry_benchmark_012 | Quantos registros de desmatamento existem no total e quantos possuem coordenadas de latitude e longitude preenchidas? Me dê o total, com latitude e com longitude. | SELECT
COUNT(*) AS total_registros,
COUNT(latitude_desmatamento) AS com_latitude,
COUNT(longitude_desmatamento) AS com_longitude
FROM
analise_dados.fato_desmatamento; | fácil | [
"desmatamento",
"qualidade_dados"
] | false | false | true |
environmental_registry_benchmark_013 | Qual a área total da terra indígena Yanomami? | SELECT
terrai_nom,
area_ti_total
FROM
analise_dados.dim_terra_indigena
WHERE
terrai_nom ILIKE '%Yanomami%'; | fácil | [
"terra_indigena"
] | false | false | true |
environmental_registry_benchmark_014 | Quantas unidades de conservação de proteção integral existem por bioma? | SELECT
biomaibge AS bioma,
COUNT(*) AS total_ucs
FROM
analise_dados.dim_unidades_conservacao
WHERE
grupouc = 'PI'
GROUP BY
biomaibge
ORDER BY
total_ucs DESC; | fácil | [
"unidade_conservacao"
] | false | false | true |
environmental_registry_benchmark_015 | Qual a área total de Reservas Extrativistas na Amazônia? | SELECT
SUM(areahaalb) AS area_total_ha
FROM
analise_dados.dim_unidades_conservacao
WHERE
siglacateg = 'RESEX'
AND biomaibge = 'AMAZÔNIA'; | fácil | [
"unidade_conservacao"
] | false | false | true |
environmental_registry_benchmark_016 | Qual a área total de terras indígenas homologadas comparada com as regularizadas? | SELECT
fase_ti,
-- COUNT(*) AS total_tis,
SUM(area_ti_total) AS area_total_ha
FROM
analise_dados.dim_terra_indigena
WHERE
fase_ti IN ('Homologada', 'Regularizada')
GROUP BY
fase_ti
ORDER BY
area_total_ha DESC; | fácil | [
"terra_indigena"
] | false | false | true |
environmental_registry_benchmark_017 | Quantos Parques Nacionais existem por bioma e qual sua área total? | SELECT
biomaibge AS bioma,
COUNT(*) AS total_parnas,
SUM(areahaalb) AS area_total_ha
FROM
analise_dados.dim_unidades_conservacao
WHERE
siglacateg = 'PARNA'
GROUP BY
biomaibge
ORDER BY
area_total_ha DESC; | fácil | [
"unidade_conservacao"
] | false | false | true |
environmental_registry_benchmark_018 | Quantos imóveis rurais ativos existem na região Norte do Brasil? | SELECT
COUNT(*) AS total_imoveis
FROM
analise_dados.dim_imovel i
JOIN analise_dados.dim_estado e ON i.cod_uf = e.cod_uf
WHERE
i.ind_tipo_imovel = 'IRU'
AND i.ind_status_imovel = 'AT'
AND e.sigla_uf IN ('AC', 'AM', 'AP', 'PA', 'RO', 'RR', 'TO'); | fácil | [
"imovel",
"região"
] | false | false | true |
environmental_registry_benchmark_019 | Qual a área total de Terras Indígenas na região Sudeste? | SELECT
SUM(fa.superficie) AS area_total_ti_ha
FROM
analise_dados.fato_area_indigena fa
WHERE
fa.uf_sigla IN ('SP', 'MG', 'RJ', 'ES'); | fácil | [
"terra_indigena",
"região"
] | false | false | true |
environmental_registry_benchmark_020 | Qual foi o desmatamento total (em hectares) por ano no bioma Amazônia? | SELECT
fd.ano_desmatamento::int AS ano,
SUM(fd.area_desmatada) AS total_desmatado_ha
FROM analise_dados.fato_desmatamento fd
WHERE
fd.bioma = 'Amazônia'
AND fd.ano_desmatamento IS NOT NULL
GROUP BY
fd.ano_desmatamento
ORDER BY
ano; | fácil | [
"temporal",
"desmatamento"
] | false | false | true |
environmental_registry_benchmark_021 | Liste todas as unidades de conservação federais da Região Sul, ordenadas por área do maior para o menor. | SELECT
uc.nomeuc,
-- uc.siglacateg,
-- uc.grupouc,
uc.areahaalb
-- uc.biomaibge
FROM analise_dados.dim_unidades_conservacao uc
WHERE uc.esferaadm = 'Federal'
AND EXISTS (
SELECT 1
FROM analise_dados.dim_estado e
WHERE e.sigla_uf IN ('PR', 'SC', 'RS')
AND ST_Intersects(uc.geo_uc, e.geo_esta... | médio | [
"unidade_conservacao",
"geografico"
] | true | false | true |
environmental_registry_benchmark_022 | Qual o estado da Região Nordeste com maior área total desmatada? | SELECT
de.nome_uf,
SUM(fd.area_desmatada) AS total_desmatado
FROM
analise_dados.fato_desmatamento fd
JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) = de.cod_uf
WHERE
de.sigla_uf IN (
'AL',
'BA',
'CE',
'MA',
'PB',
'PE',
'P... | médio | [
"desmatamento",
"geografico"
] | false | false | false |
environmental_registry_benchmark_023 | Qual a soma de área desmatada nos estados do Centro-Oeste em 2022 em hectares? | SELECT
SUM(fd.area_desmatada) AS total_desmatado_ha
FROM
analise_dados.fato_desmatamento fd
JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) = de.cod_uf
WHERE
de.sigla_uf IN ('DF', 'GO', 'MS', 'MT')
AND fd.ano_desmatamento = 2022; | médio | [
"desmatamento",
"geografico"
] | false | false | true |
environmental_registry_benchmark_024 | Quais são os municípios do Maranhão com desmatamento registrado no bioma Cerrado? | SELECT DISTINCT
dm.mun_nome
FROM
analise_dados.fato_desmatamento fd
JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
JOIN analise_dados.dim_municipio dm ON di.cod_mun = CAST(dm.cod_mun AS int4)
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) = de.cod_uf
WHERE
de.sigla_uf = 'MA'
AND U... | médio | [
"desmatamento",
"geografico"
] | false | false | true |
environmental_registry_benchmark_025 | Qual a área média em hectares dos imóveis rurais por estado da Região Nordeste? | SELECT
de.nome_uf,
-- de.sigla_uf,
AVG(di.area_imovel) AS area_media_ha
-- COUNT(*) AS total_imoveis
FROM
analise_dados.dim_imovel di
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) = de.cod_uf
WHERE
di.ind_tipo_imovel = 'IRU'
AND de.sigla_uf IN (
'AL',
'BA',
'CE',
'MA',
'PB',
'PE',
'P... | médio | [
"imovel",
"geografico"
] | false | false | true |
environmental_registry_benchmark_026 | Quais são os 10 municípios do Mato Grosso com maior área desmatada acumulada em hectares? | SELECT
dm.mun_nome,
SUM(fd.area_desmatada) AS area_desmatada_total_ha
FROM
analise_dados.fato_desmatamento fd
JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
JOIN analise_dados.dim_municipio dm ON di.cod_mun = CAST(dm.cod_mun AS int4)
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) =... | médio | [
"desmatamento",
"geografico"
] | true | false | true |
environmental_registry_benchmark_027 | Qual a evolução anual do desmatamento no bioma Cerrado nos estados do Centro-Oeste? Dê a área desmatada em hectáres por ano para cada estado. | SELECT
fd.ano_desmatamento,
de.sigla_uf,
SUM(fd.area_desmatada) AS area_desmatada_ha
FROM
analise_dados.fato_desmatamento fd
JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) = de.cod_uf
WHERE
de.sigla_uf IN ('DF', 'GO', 'MS', 'MT')
AND... | médio | [
"desmatamento",
"geografico",
"temporal"
] | false | false | true |
environmental_registry_benchmark_028 | Compare a área total de unidades de conservação de uso sustentável vs. proteção integral no bioma Mata Atlântica, agrupado por esfera administrativa. Me dê a esferaadm, o nome do grupo (Proteção Integral, Uso Sustentável) e a área total. | SELECT
uc.esferaadm,
-- uc.grupouc,
CASE
WHEN uc.grupouc = 'PI' THEN 'Proteção Integral'
ELSE 'Uso Sustentável'
END AS grupo_descricao,
-- COUNT(*) AS total_ucs,
SUM(uc.areahaalb) AS area_total_ha
FROM
analise_dados.dim_unidades_conservacao uc
WHERE
UPPER(uc.biomaibge) = 'MATA ATLÂNTICA'
GROUP BY
uc.esfera... | médio | [
"unidade_conservacao",
"geografico"
] | false | true | true |
environmental_registry_benchmark_029 | Calcule a área geográfica real em km2 de cada estado do Nordeste usando a sua geometria espacial. Me dê a sigla, nome e área. | SELECT
sigla_uf,
nome_uf,
ROUND((ST_Area(geo_estado) / 1000000)::numeric, 2) AS area_km2
FROM dim_estado
WHERE sigla_uf IN ('AL', 'BA', 'CE', 'MA', 'PB', 'PE', 'PI', 'RN', 'SE')
ORDER BY sigla_uf; | médio | [
"geoespacial",
"geografico"
] | false | true | true |
environmental_registry_benchmark_030 | Qual a área média em ha dos CARs classificados como Grande no estado de minas? | SELECT
AVG(i.area_imovel) AS area_media_hectares
FROM
dim_imovel i
INNER JOIN dim_estado e ON i.cod_uf = e.cod_uf
WHERE
e.cod_uf = 31
AND i.class_tam_imovel = 'Grande' | médio | [
"imovel"
] | false | false | true |
environmental_registry_benchmark_031 | Quais são os 10 municípios com maior número de imóveis rurais cadastrados? | SELECT
m.mun_nome AS municipio,
COUNT(*) AS numero_imoveis
FROM analise_dados.dim_imovel i
INNER JOIN analise_dados.dim_municipio m ON i.cod_mun = m.cod_mun
WHERE i.ind_tipo_imovel = 'IRU'
GROUP BY m.mun_nome
ORDER BY numero_imoveis DESC
LIMIT 10 | médio | [
"imovel"
] | true | false | true |
environmental_registry_benchmark_032 | Qual o bioma com maior área desmatada acumulada nos últimos 5 anos (2019 a 2023)? | SELECT
fd.bioma,
SUM(fd.area_desmatada) AS area_total_desmatada_ha
FROM
analise_dados.fato_desmatamento fd
WHERE
fd.ano_desmatamento >= 2019
AND fd.ano_desmatamento <= 2023
GROUP BY
fd.bioma
ORDER BY
area_total_desmatada_ha DESC
LIMIT
1; | médio | [
"desmatamento",
"temporal"
] | false | false | false |
environmental_registry_benchmark_033 | Quantos eventos de desmatamento foram registrados por ano nos imóveis rurais? | SELECT
fd.ano_desmatamento,
COUNT(*) AS total_eventos
FROM
analise_dados.fato_desmatamento fd
INNER JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
WHERE
di.ind_tipo_imovel = 'IRU'
GROUP BY
fd.ano_desmatamento
ORDER BY
fd.ano_desmatamento; | médio | [
"desmatamento",
"temporal"
] | false | false | true |
environmental_registry_benchmark_034 | Qual a distribuição dos índices de similaridade Jaccard entre parcelas SIGEF e imóveis CAR por faixa percentual no Sul do Brasil? Eu quero a faixa percentual, o totals de pares e o jaccard médio. | SELECT
fss.faixa_percent_similaridade AS faixa_percentual,
COUNT(*) AS total_pares,
ROUND(AVG(fss.indice_jaccard), 4) AS jaccard_medio
FROM fato_similaridade_sigef fss
JOIN dim_imovel di ON fss.cod_imovel = di.cod_imovel
JOIN dim_estado de ON di.cod_uf = de.cod_uf
WHERE de.sigla_uf IN ('PR', 'SC', 'RS')
GRO... | médio | [
"sigef"
] | false | false | true |
environmental_registry_benchmark_035 | Quais são os 10 municípios (nome e área) com maior área total de imóveis rurais cadastrados? Maior para menor. | SELECT
dm.mun_nome,
SUM(di.area_imovel) AS area_total_ha
FROM
analise_dados.dim_imovel di
JOIN analise_dados.dim_municipio dm ON di.cod_mun = CAST(dm.cod_mun AS int4)
WHERE
di.ind_tipo_imovel = 'IRU'
GROUP BY
dm.mun_nome
ORDER BY
area_total_ha DESC
LIMIT
10; | médio | [
"imovel"
] | true | false | true |
environmental_registry_benchmark_036 | Quantos embargos ambientais foram registrados por motivo de desmatamento ou queimada no ano de 2022? | SELECT
COUNT(id_embargo) AS total_embargos
FROM
analise_dados.dim_embargo
WHERE
sit_desmat = 'D'
AND EXTRACT(
YEAR
FROM
TO_DATE (dat_embarg, 'DD/MM/YY HH24:MI:SS')
) = 2022; | médio | [
"embargo",
"temporal"
] | false | false | true |
environmental_registry_benchmark_037 | Determine a proporção de imóveis rurais classificados como Médios ou Grandes (via CAR) que possuem índice de similaridade de Jaccard no SIGEF entre 0.9 e 1.0. | WITH total_imoveis AS (
SELECT COUNT(DISTINCT cod_imovel) as total_médio_grande
FROM analise_dados.dim_imovel
WHERE ind_tipo_imovel = 'IRU'
AND class_tam_imovel IN ('Médio', 'Grande')
),
imoveis_com_alta_similaridade AS (
SELECT COUNT(DISTINCT fs.cod_imovel) as com_alta_similaridade
FROM anali... | médio | [
"imovel",
"sigef"
] | false | false | true |
environmental_registry_benchmark_038 | Qual a proporção de parcelas SIGEF que possuem matrícula registrada versus as que não possuem, por status? Dê os valores absolutos e porcentuais dos dados para melhor visualização. | SELECT
status,
COUNT(*) AS total_parcelas,
SUM(CASE WHEN registro_matricula = TRUE THEN 1 ELSE 0 END) AS com_matricula,
SUM(CASE WHEN registro_matricula = FALSE THEN 1 ELSE 0 END) AS sem_matricula,
ROUND(100.0 * SUM(CASE WHEN registro_matricula = TRUE THEN 1 ELSE 0 END) / COUNT(*), 2) AS proporcao_... | médio | [
"sigef",
"qualidade_dados"
] | false | false | true |
environmental_registry_benchmark_039 | Por estado, quantos imóveis rurais possuem geometria e quantos não possuem? Mostre o percentual de completude. | SELECT
de.sigla_uf,
COUNT(*) AS total_imoveis,
COUNT(di.geo_imovel) AS com_geometria,
COUNT(*) - COUNT(di.geo_imovel) AS sem_geometria,
ROUND(
100.0 * COUNT(di.geo_imovel) / NULLIF(COUNT(*), 0),
2
) AS percentual_completude
FROM
analise_dados.dim_imovel di
JOIN analise_da... | médio | [
"imovel",
"qualidade_dados"
] | false | false | true |
environmental_registry_benchmark_040 | Qual a área total em hectares das unidades de conservação por esfera administrativa, ignorando aquelas que não possuem área oficial preenchida? | SELECT
esferaadm,
SUM(areahaalb) AS area_total_ha
FROM
analise_dados.dim_unidades_conservacao
WHERE
areahaalb IS NOT NULL
GROUP BY
esferaadm; | médio | [
"unidade_conservacao",
"qualidade_dados"
] | false | false | true |
environmental_registry_benchmark_041 | Quais as 10 terras indígenas com o maior número de CARs distintos sobrepostos? Maior para menor. | SELECT
-- ti.terrai_cod,
ti.terrai_nom AS nome_terra_indigena,
COUNT(DISTINCT f.cod_imovel) AS numero_imoveis_sobrepostos
FROM fato_sobreposicao_terra_indigena f
JOIN dim_terra_indigena ti
ON f.terrai_cod = ti.terrai_cod
GROUP BY
ti.terrai_cod,
ti.terrai_nom
ORDER BY
numero_imoveis_sobrepostos DESC,
ti.... | médio | [
"terra_indigena",
"sobreposicao"
] | false | false | true |
environmental_registry_benchmark_042 | Qual o ranking dos 10 imóveis com o maior número de embargos distintos associados? | SELECT fse.cod_imovel,
COUNT(DISTINCT fse.id_embargo) AS total_embargos
FROM analise_dados.fato_sobreposicao_embargo fse
GROUP BY fse.cod_imovel
ORDER BY total_embargos DESC
LIMIT 10; | médio | [
"embargo",
"sobreposicao"
] | false | false | true |
environmental_registry_benchmark_043 | Qual a distribuição de assentamentos por região do Brasil? Coloque os assentamentos sem região em duas categorias: Código de UF inválido e UF não informada | WITH
regiao_map AS (
SELECT
sigla_uf,
CASE
WHEN sigla_uf IN ('AC', 'AP', 'AM', 'PA', 'RO', 'RR', 'TO') THEN 'Norte'
WHEN sigla_uf IN (
'AL',
'BA',
'CE',
'MA',
'PB',
'PE',
'PI',
'RN',
'SE'
... | médio | [
"assentamento",
"região"
] | false | false | true |
environmental_registry_benchmark_044 | Qual a gleba federal com mais imóveis rurais sobrepostos? | SELECT
tu.nome_gleba,
-- tu.area_tu,
COUNT(DISTINCT ft.cod_imovel) AS total_imoveis
FROM
analise_dados.fato_imovel_terra_uniao ft
JOIN analise_dados.dim_terra_uniao tu ON ft.id_tu = tu.id_tu
JOIN analise_dados.dim_imovel i ON ft.cod_imovel = i.cod_imovel
WHERE
i.ind_tipo_imovel = 'IRU'
GROUP... | médio | [
"terra_uniao",
"sobreposição"
] | false | false | true |
environmental_registry_benchmark_045 | Quais as 10 unidades de conservação de proteção integral com o maior número de imóveis sobrepostos? | SELECT
duc.nomeuc,
-- duc.siglacateg,
COUNT(DISTINCT fsuc.cod_imovel) AS total_imoveis_sobrepostos
FROM
analise_dados.fato_sobreposicao_unidades_conservacao fsuc
JOIN analise_dados.dim_unidades_conservacao duc ON fsuc.cnuc = duc.cnuc
WHERE
duc.grupouc = 'PI'
GROUP BY
duc.nomeuc,
duc.sigl... | médio | [
"unidade_conservacao",
"sobreposicao"
] | false | false | true |
environmental_registry_benchmark_046 | Quantos imóveis rurais ativos existem em cada estado, mostrando o nome completo do estado? Do maior para menor | SELECT
de.nome_uf,
COUNT(di.cod_imovel) AS total_imoveis
FROM
analise_dados.dim_imovel di
JOIN analise_dados.dim_estado de ON CAST(di.cod_uf AS int4) = de.cod_uf
WHERE
di.ind_tipo_imovel = 'IRU'
AND di.ind_status_imovel = 'AT'
GROUP BY
de.nome_uf
ORDER BY
total_imoveis DESC; | médio | [
"imovel"
] | true | false | true |
environmental_registry_benchmark_047 | Qual a área total desmatada por ano, considerando apenas imóveis rurais no bioma Cerrado? | SELECT
CAST(fd.ano_desmatamento AS INTEGER) as ano,
SUM(fd.area_desmatada) as area_total_desmatada_hectares
FROM analise_dados.fato_desmatamento fd
INNER JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
WHERE fd.bioma = 'Cerrado'
AND di.ind_tipo_imovel = 'IRU'
GROUP BY fd.ano_desmatamento
OR... | médio | [
"desmatamento",
"temporal"
] | false | false | true |
environmental_registry_benchmark_048 | Quantos embargos por desmatamento estão sobrepostos a imóveis rurais grandes, e qual a área total de sobreposição? | SELECT
COUNT(DISTINCT fse.id_embargo) AS qtd_embargos,
SUM(fse.area_embar_car) AS area_total_sobreposicao
FROM
fato_sobreposicao_embargo fse
JOIN dim_embargo de ON fse.id_embargo = de.id_embargo
JOIN dim_imovel di ON fse.cod_imovel = di.cod_imovel
WHERE
de.sit_desmat = 'D'
AND di.class_tam_imovel = 'Grand... | médio | [
"embargo",
"sobreposicao",
"imovel"
] | false | false | true |
environmental_registry_benchmark_049 | Quantas parcelas SIGEF vinculadas a CARs foram aprovadas em 2023, agrupadas por natureza e status e agrupados pelos mesmos na mesma ordem? | SELECT
ds.natureza,
ds.status,
COUNT(DISTINCT ds.parcela_codigo) AS qtd_parcelas
FROM fato_similaridade_sigef fss
JOIN dim_sigef ds
ON fss.parcela_codigo = ds.parcela_codigo
WHERE ds.data_aprovacao >= '2023/01/01'
AND ds.data_aprovacao < '2024/01/01'
GROUP BY ds.natureza, ds.status
ORDER BY ds.nature... | médio | [
"sigef",
"temporal"
] | false | false | true |
environmental_registry_benchmark_050 | Compare o número de imóveis rurais com desmatamento em 2024 e a soma da área desmatada, agrupados por UF.
| SELECT
de.sigla_uf,
COUNT(DISTINCT fd.cod_imovel) AS total_imoveis,
SUM(fd.area_desmatada) AS soma_area_desmatada_ha
FROM
analise_dados.fato_desmatamento fd
JOIN analise_dados.dim_imovel di
ON fd.cod_imovel = di.cod_imovel
JOIN analise_dados.dim_estado de
ON di.cod_uf = de.cod_uf
WHERE
di.ind_tipo... | médio | [
"embargo",
"sobreposicao"
] | false | false | true |
environmental_registry_benchmark_051 | Qual a área total desmatada em Novo Progresso nos últimos 5 anos registrados? | WITH
ultimos_anos AS (
SELECT DISTINCT
ano_desmatamento
FROM
analise_dados.fato_desmatamento
ORDER BY
ano_desmatamento DESC
LIMIT
5
)
SELECT
-- dm.mun_nome,
SUM(fd.area_desmatada) AS total_desmatado_ha
FROM
analise_dados... | difícil | [
"desmatamento",
"geografico",
"temporal"
] | false | false | true |
environmental_registry_benchmark_052 | Quantos imóveis rurais grandes existem em cada estado da Região Norte, e qual o percentual em relação ao total de imóveis do estado? Me dê o nome do estado, o total de imóvies e o total e a porcentagem de grandes. | WITH
imoveis_norte AS (
SELECT
de.sigla_uf,
de.nome_uf,
COUNT(*) AS total_imoveis,
COUNT(*) FILTER (
WHERE
di.class_tam_imovel = 'Grande'
) AS grandes
FROM
analise_dados.dim_imovel di
... | difícil | [
"imovel",
"geografico"
] | false | false | true |
environmental_registry_benchmark_053 | Quais imóveis rurais ativos possuem sobreposição com terra indígena, mas não com embargo, e cujo percentual de sobreposição com TI é superior a 75%? Me dê o código do imóvel, área do imóvel, porcetangem de sobreposição e nome da TI | SELECT
di.cod_imovel,
di.area_imovel,
fsti.percent_car_ti,
dti.terrai_nom
FROM
analise_dados.dim_imovel di
INNER JOIN analise_dados.fato_sobreposicao_terra_indigena fsti ON di.cod_imovel = fsti.cod_imovel
INNER JOIN analise_dados.dim_terra_indigena dti ON fsti.terrai_cod = dti.terrai_cod
WHE... | difícil | [
"imovel",
"terra_indigena",
"embargo",
"sobreposicao"
] | false | true | true |
environmental_registry_benchmark_054 | Qual o percentual de imóveis rurais ativos por classificação de tamanho em cada estado? Me dê a sigla do estado, a classe, a quantidade de imóveis e o percentual. | SELECT
de.sigla_uf,
di.class_tam_imovel,
COUNT(*) AS total,
ROUND(
COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (
PARTITION BY
de.sigla_uf
),
2
) AS percentual
FROM
analise_dados.dim_imovel di
INNER JOIN analise_dados.dim_estado de ON CAST(di.cod_... | difícil | [
"imovel"
] | false | true | true |
environmental_registry_benchmark_055 | Quais são os imóveis rurais que tiveram desmatamento em 2023 no bioma Cerrado e também possuem sobreposição com embargos? | SELECT di.cod_imovel
FROM analise_dados.dim_imovel di
WHERE di.ind_tipo_imovel = 'IRU'
AND EXISTS (
SELECT 1
FROM analise_dados.fato_desmatamento fd
WHERE fd.cod_imovel = di.cod_imovel
AND fd.ano_desmatamento = 2023.0
AND UPPER(fd.bioma) = 'CERRADO'
)
AND EXISTS (
SELECT 1
FROM ana... | difícil | [
"desmatamento",
"embargo",
"sobreposicao"
] | false | false | true |
environmental_registry_benchmark_056 | Qual o ranking dos municípios com maior área desmatada acumulada em imóveis rurais? Me dê o TOP 20 ordenado por ranking (ranking é uma coluna com 1, 2, 3...) | WITH desmat_mun AS (
SELECT di.cod_mun, SUM(fd.area_desmatada) AS area_desmatada_total_ha
FROM analise_dados.fato_desmatamento fd
INNER JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
WHERE di.ind_tipo_imovel = 'IRU'
GROUP BY di.cod_mun
)
SELECT dm.mun_nome, d.area_desmatada_total_ha,
... | difícil | [
"desmatamento",
"imovel"
] | false | false | true |
environmental_registry_benchmark_057 | Qual o percentual médio de sobreposição de Terras Indígenas nos imóveis rurais que possuem embargo por desmatamento? | WITH imoveis_com_embargo_desmat AS (
SELECT DISTINCT fse.cod_imovel
FROM analise_dados.fato_sobreposicao_embargo fse
JOIN analise_dados.dim_embargo de ON de.id_embargo = fse.id_embargo
WHERE de.sit_desmat = 'D'
),
percentual_por_imovel AS (
SELECT
iced.cod_imovel,
COALESCE(SUM(fsti.... | difícil | [
"sobreposicao",
"terra_indigena",
"embargo"
] | false | false | true |
environmental_registry_benchmark_058 | Para o município de Altamira, calcule em hectares a soma da área dos imóveis rurais do CAR e a soma da área das parcelas do SIGEF que intersectam o município, considerando somente a porção da parcela dentro do limite municipal. Retorne o resultado em uma única linha, com uma coluna para `total_car_ha` e outra para `tot... | WITH altamira AS (
SELECT geo_mun
FROM analise_dados.dim_municipio
WHERE cod_mun = 1500602
),
car AS (
SELECT
SUM(di.area_imovel) AS total_car_ha
FROM analise_dados.dim_imovel di
WHERE di.cod_mun = 1500602
AND di.ind_tipo_imovel = 'IRU'
),
sigef AS (
SELECT
SUM(
ST_Area(
ST_Inter... | difícil | [
"imovel",
"sigef"
] | false | false | true |
environmental_registry_benchmark_059 | Entre as parcelas SIGEF registradas e matriculadas que intersectam imóveis rurais (IRU), qual é a diferença percentual entre a soma da área registrada no SIGEF e a soma da área de interseção com esses imóveis? Retorne a área SIGEF registrada total, a área de interseção total, a diferença absoluta e a diferença percentu... | WITH parcelas_base AS (
SELECT DISTINCT
s.parcela_codigo,
s.area_hectares
FROM analise_dados.dim_sigef s
JOIN analise_dados.fato_similaridade_sigef f
ON f.parcela_codigo = s.parcela_codigo
JOIN analise_dados.dim_imovel i
ON i.cod_imovel = f.cod_imovel
WHERE s.status = 'REGISTRADA'
AND s.re... | difícil | [
"sigef",
"sobreposicao"
] | false | false | true |
environmental_registry_benchmark_060 | Qual a taxa de ocupação de assentamentos (famílias/capacidade) por região? Use outros para assentamentos que estão sem região no BD. | SELECT
regiao,
-- SUM(capacidade) AS capacidade_total,
-- SUM(num_famili) AS familias_total,
CASE
WHEN SUM(capacidade) = 0 THEN NULL
ELSE ROUND(SUM(num_famili)::numeric / SUM(capacidade) * 100, 2)
END AS taxa_ocupacao_pct
-- COUNT(*) ... | difícil | [
"assentamento",
"região"
] | false | false | true |
environmental_registry_benchmark_061 | Ranqueie os estados pela área em hectares total de desmatamento acumulado entre 2015 e 2023, mostrando também o percentual que cada estado representa no total nacional. Ordene pelo ranking | WITH desmatamento_estado AS (
SELECT
e.sigla_uf,
e.nome_uf,
SUM(d.area_desmatada) AS area_total_ha
FROM analise_dados.fato_desmatamento d
JOIN analise_dados.dim_imovel i ON d.cod_imovel = i.cod_imovel
JOIN analise_dados.dim_estado e ON i.cod_uf = e.cod_uf
WHERE d.ano_desmatam... | difícil | [
"desmatamento",
"imovel"
] | false | false | true |
environmental_registry_benchmark_062 | Calcule a evolução anual do desmatamento no bioma Cerrado, incluindo a variação percentual em relação ao ano anterior. | WITH desmat_anual AS (
SELECT
CAST(fd.ano_desmatamento AS int) AS ano,
SUM(fd.area_desmatada) AS area_total
FROM analise_dados.fato_desmatamento fd
WHERE fd.bioma = 'Cerrado'
GROUP BY CAST(fd.ano_desmatamento AS int)
)
SELECT
ano,
area_total,
LAG(area_total) OVER (ORDER BY ano) AS area_ano_anterio... | difícil | [
"desmatamento",
"temporal"
] | false | false | true |
environmental_registry_benchmark_063 | Para cada bioma presente na tabela de desmatamento, considere apenas os imóveis rurais que possuem ao menos um registro em fato_desmatamento. Some a área desmatada de cada imóvel dentro de cada bioma, calcule o desmatamento médio por imóvel em cada bioma e, em seguida, calcule o desvio dessa média em relação à média na... | WITH media_nacional AS (
SELECT
SUM(fd.area_desmatada) / COUNT(DISTINCT fd.cod_imovel) AS media_nacional
FROM fato_desmatamento fd
JOIN dim_imovel di ON fd.cod_imovel = di.cod_imovel
WHERE di.ind_tipo_imovel = 'IRU'
),
media_bioma AS (
SELECT
fd.bioma,
SUM(fd.area_desmatada... | difícil | [
"desmatamento"
] | false | false | true |
environmental_registry_benchmark_064 | Para cada estado, qual o percentual de imóveis rurais ativos classificados como Pequeno, Médio e Grande? Apresente como colunas separadas e use os nomes dos estado para cada linha. | SELECT
e.nome_uf AS estado,
ROUND(
100.0 * COUNT(*) FILTER (
WHERE
i.class_tam_imovel = 'Pequeno'
) / COUNT(*),
2
) AS pct_pequeno,
ROUND(
100.0 * COUNT(*) FILTER (
WHERE
i.class_tam_imovel = 'Médio'
) / COUNT(*),
2
) AS pct_medio,
ROUND(
100.0 * COUNT... | difícil | [
"imovel"
] | false | false | true |
environmental_registry_benchmark_065 | Calcule o percentil de cada imóvel rural ativo em termos de área dentro do seu estado da região Sul. Mostre os imóveis que estão acima do percentil 95. Me dê a área em hectares e o percentil em uma escla de 0 a 100. | WITH imoveis_sul AS (
SELECT
i.cod_imovel,
e.sigla_uf,
i.area_imovel,
PERCENT_RANK() OVER (PARTITION BY i.cod_uf ORDER BY i.area_imovel) * 100 AS percentil
FROM dim_imovel i
JOIN dim_estado e ON i.cod_uf = e.cod_uf
WHERE i.ind_tipo_imovel = 'IRU'
AND i.ind_status_im... | difícil | [
"imovel"
] | false | false | true |
environmental_registry_benchmark_066 | Para cada unidade de conservação federal, calcule a quantidade de imóveis sobrepostos e a média do percentual de sobreposição. Exiba apenas UCs com mais de 50 imóveis sobrepostos, ranqueadas pela média de sobreposição. Dê cnuc e o nome da UC também. Ordene pela média e pelo nome, sendo a média do maior para o menor. | SELECT
uc.cnuc,
uc.nomeuc,
-- uc.siglacateg,
-- uc.grupouc,
COUNT(DISTINCT fuc.cod_imovel) AS qtd_imoveis_sobrepostos,
ROUND(AVG(fuc.percent_car_uc), 2) AS media_percent_sobreposicao
FROM
analise_dados.dim_unidades_conservacao uc
JOIN analise_dados.fato_sobreposicao_unidades_conservacao ... | difícil | [
"unidade_conservacao",
"sobreposicao"
] | true | false | true |
environmental_registry_benchmark_067 | Compare a área declarada no CAR com a área da parcela SIGEF para parcelas com índice de Jaccard abaixo de 0.5. Mostre as 30 maiores discrepâncias absolutas. | SELECT
fs.cod_imovel,
fs.parcela_codigo,
di.area_imovel AS area_car,
ds.area_hectares AS area_sigef,
fs.indice_jaccard,
ABS(di.area_imovel - ds.area_hectares) AS discrepancia_absoluta
FROM analise_dados.fato_similaridade_sigef fs
JOIN analise_dados.dim_imovel di ON fs.cod_imovel = di.cod_imovel
JOIN analise... | difícil | [
"sigef",
"imovel"
] | false | false | true |
environmental_registry_benchmark_068 | Para cada estado, qual o top 3 de municípios em área desmatada acumulada? Apresente sigla do estado, nome do município, área desmatada em hectares e a posição no ranking estadual. | WITH desmat_mun AS (
SELECT
de.sigla_uf,
dm.mun_nome,
SUM(fd.area_desmatada) AS area_desmatada,
ROW_NUMBER() OVER (PARTITION BY de.sigla_uf ORDER BY SUM(fd.area_desmatada) DESC) AS rn
FROM analise_dados.fato_desmatamento fd
JOIN analise_dados.dim_imovel di ON fd.cod_imovel = di.cod_imovel
JOIN a... | difícil | [
"desmatamento",
"imovel"
] | false | false | true |
environmental_registry_benchmark_069 | Qual o menor e o maior CARs pendente em área por estado da região Nordeste? Mê de o nome do estado, código do CAR, cidade do CAR e o tamnho em km² | WITH
imoveis_nordeste AS (
SELECT
e.sigla_uf,
e.nome_uf,
i.cod_imovel,
m.mun_nome,
i.area_imovel * 0.01 AS area_km2,
i.ind_status_imovel,
i.ind_tipo_imovel
FROM
dim_imovel i
JOIN dim_estado e ON i.cod_uf = e.cod_uf
JOIN dim_municipio m ON i.cod_mun =... | difícil | [
"imovel",
"geoespacial"
] | false | false | true |
environmental_registry_benchmark_070 | Mostre o acumulado progressivo (running total) da área desmatada por ano no bioma Amazônia, de 2008 a 2023. | WITH desmat_anual AS (
SELECT
CAST(fd.ano_desmatamento AS int) AS ano,
SUM(fd.area_desmatada) AS area_ano
FROM analise_dados.fato_desmatamento fd
WHERE fd.bioma = 'Amazônia'
AND fd.ano_desmatamento BETWEEN 2008 AND 2023
GROUP BY CAST(fd.ano_desmatamento AS int)
)
SELECT
ano,
area_ano,
SUM(area... | difícil | [
"desmatamento",
"temporal"
] | false | false | true |
environmental_registry_benchmark_071 | Identifique os imóveis rurais que aparecem simultaneamente nas tabelas de sobreposição com embargos, terras indígenas e unidades de conservação. Quantos são por estado? | WITH uc_sem_apa AS (
SELECT DISTINCT
uc.cod_imovel
FROM analise_dados.fato_sobreposicao_unidades_conservacao uc
JOIN analise_dados.dim_unidades_conservacao duc
ON duc.cnuc = uc.cnuc
WHERE COALESCE(UPPER(duc.siglacateg), '') <> 'APA'
),
tripla_sobrep AS (
SELECT cod_imovel
FROM analise_dados.fato_sob... | difícil | [
"sobreposicao",
"embargo",
"terra_indigena",
"unidade_conservacao"
] | false | false | true |
environmental_registry_benchmark_072 | Calcule para cada município do Mato Grosso o total de área desmatada, número de CARs com desmatamento e a área média desmatada por imóvel. Ranqueie pelo total de área desmatada. | SELECT
m.mun_nome AS municipio,
SUM(d.area_desmatada) AS area_desmatada_total_ha,
COUNT(DISTINCT d.cod_imovel) AS num_imoveis_com_desmatamento,
ROUND(SUM(d.area_desmatada) / COUNT(DISTINCT d.cod_imovel), 2) AS area_media_desmatada_por_imovel_ha
FROM fato_desmatamento d
JOIN dim_imovel i ON d.cod_imovel... | difícil | [
"desmatamento",
"imovel"
] | false | false | false |
environmental_registry_benchmark_073 | Para cada bioma, identifique o ano com maior desmatamento e o ano com menor desmatamento. Mostre os valores correspondentes em ha. | WITH desmat_bioma_ano AS (
SELECT
fd.bioma,
CAST(fd.ano_desmatamento AS int) AS ano,
SUM(fd.area_desmatada) AS area_total
FROM analise_dados.fato_desmatamento fd
GROUP BY fd.bioma, CAST(fd.ano_desmatamento AS int)
),
ranked AS (
SELECT
bioma,
ano,
area_total,
ROW_NUMBER() OVER (PARTI... | difícil | [
"desmatamento",
"temporal"
] | false | false | true |
environmental_registry_benchmark_074 | Quais imóveis tiveram desmatamento registrado em 3 ou mais anos distintos no menor estado do Nordeste em área? Mostre o código do imóvel, quantidade de anos, lista de anos divida por virgula sem espaço e a área total desmatada em ha. | SELECT
fd.cod_imovel,
COUNT(DISTINCT fd.ano_desmatamento) AS quantidade_anos,
STRING_AGG(DISTINCT CAST(CAST(ROUND(fd.ano_desmatamento) AS INTEGER) AS VARCHAR), ',' ORDER BY CAST(CAST(ROUND(fd.ano_desmatamento) AS INTEGER) AS VARCHAR)) AS lista_anos,
SUM(fd.area_desmatada) AS area_total_desmatada
FROM fa... | difícil | [
"desmatamento",
"temporal"
] | false | false | true |
environmental_registry_benchmark_075 | Identifique UCs do bioma Amazônia que foram criadas antes de 2000 e que possuem mais de 100 imóveis sobrepostos. Mostre o nome da uc, o ano de criação, número de imóveis e área total de sobreposição em ha. Ordene pela quantidade de imóveis (maior para menor) | SELECT
uc.nomeuc AS nome_uc,
uc.criacaoano AS ano_criacao,
COUNT(*) AS numero_imoveis,
ROUND(SUM(f.area_uc_car), 2) AS area_total_sobreposicao_ha
FROM analise_dados.dim_unidades_conservacao uc
JOIN analise_dados.fato_sobreposicao_unidades_conservacao f
ON uc.cnuc = f.cnuc
WHERE uc.biomaibge = 'AMAZÔNIA'
AND... | difícil | [
"unidade_conservacao",
"sobreposicao"
] | true | true | true |
environmental_registry_benchmark_076 | Me dê a quantidade de embargos por estado em 2023? Use a técnica da maior área para embargos que estão entre estados. Mê de exatamente 2 colunas: nome do estado e quantidade de embargos. Ordene pela quantidade de emb de maneira descendente. | WITH embargos_2023 AS (
-- Filtra embargos do ano de 2023
SELECT
id_embargo,
geo_embargo,
ST_Area(geo_embargo) as area_total
FROM dim_embargo
WHERE SUBSTRING(dat_embarg FROM '\d{2}/\d{2}/(\d{2})') = '23'
),
interseccoes AS (
-- Calcula a interseção entre cada embargo e cada ... | difícil | [
"terra_indigena",
"sobreposicao"
] | true | true | true |
environmental_registry_benchmark_077 | Para cada gleba federal, identifique quantos dos imóveis rurais sobrepostos tiveram desmatamento registrado entre 2020 e 2023. Mostre o nome da gleba, a situação, o total de imóveis rurais sobrepostos, quantos possuem desmatamento no período, a área total desmatada nesses imóveis e o percentual de imóveis com desmatame... | WITH imoveis_gleba AS (
SELECT
fitu.id_tu,
fitu.cod_imovel
FROM analise_dados.fato_imovel_terra_uniao fitu
JOIN analise_dados.dim_imovel di
ON fitu.cod_imovel = di.cod_imovel
WHERE di.ind_tipo_imovel = 'IRU'
),
desmat_por_imovel_gleba AS (
SELECT
ig.id_tu,
ig.... | difícil | [
"terra_uniao",
"desmatamento",
"sobreposicao",
"temporal"
] | false | true | true |
environmental_registry_benchmark_078 | Para cada bioma, calcule a evolução anual do desmatamento em imóveis rurais, exibindo a área desmatada no ano e a variação percentual em relação ao ano anterior. | WITH
desmatamento_por_bioma_ano AS (
SELECT
fd.bioma,
CAST(fd.ano_desmatamento AS INTEGER) AS ano,
SUM(fd.area_desmatada) AS area_desmatada_total
FROM
fato_desmatamento fd
JOIN dim_imovel di ON fd.cod_imovel = di.cod_imovel
WHERE
di.ind_tipo_imovel = 'IRU'
GROUP BY
... | difícil | [
"desmatamento",
"temporal"
] | false | false | true |
environmental_registry_benchmark_079 | Para cada terra indígena na fase 'Homologada', calcule o número de imóveis rurais sobrepostos e a densidade de conflito (área de sobreposição dividida pela área total da TI). Me dê o nome da TI, a área em ha, quantidade de imóveis sobrepostos, área total sobreposta e o cálculo da densidade de conflito bruta. | SELECT
ti.terrai_nom AS nome_ti,
ti.area_ti_total AS area_ti_ha,
COUNT(*)::integer AS qtd_imoveis_sobrepostos,
ROUND(SUM(f.area_ti_car), 2) AS area_total_sobreposta_ha,
ROUND((SUM(f.area_ti_car) / ti.area_ti_total)::numeric, 4) AS densidade_conflito_bruta
FROM fato_sobreposicao_terra_indigena f
JOI... | difícil | [
"terra_indigena",
"sobreposicao"
] | false | false | false |
environmental_registry_benchmark_080 | Por estado, qual a taxa de inconsistência entre a classificação de tamanho do imóvel e a classe recalculada a partir de num_modulo_fiscal nos imóveis rurais ativos ? Use a siglas do estado para cada linha. | WITH base AS (
SELECT
e.sigla_uf,
i.class_tam_imovel,
i.num_modulo_fiscal,
CASE
WHEN i.num_modulo_fiscal <= 4 THEN 'Pequeno'
WHEN i.num_modulo_fiscal <= 15 THEN 'Médio'
ELSE 'Grande'
END AS class_recalculada,
CASE
WHEN i... | difícil | [
"imovel",
"qualidade_dados"
] | false | false | true |
environmental_registry_benchmark_081 | Entre os estados com pelo menos 50 mil imóveis IRU ativos, qual o ranking por percentual da área total em dupla pressão territorial (imóveis que sobrepõem simultaneamente Terra Indígena e UC não-APA), incluindo percent_rank nacional? | WITH imoveis_iru_ativos AS (
SELECT
di.cod_imovel,
di.cod_uf,
COALESCE(di.area_imovel, 0) AS area_imovel
FROM analise_dados.dim_imovel di
WHERE di.ind_tipo_imovel = 'IRU'
AND di.ind_status_imovel = 'AT'
),
estados_elegiveis AS (
SELECT
iia.cod_uf
FROM imoveis_ir... | expert | [
"unidade_conservacao",
"geografico",
"geoespacial"
] | false | false | true |
environmental_registry_benchmark_082 | Nos 3 anos mais recentes com desmatamento na base, qual a participação de cada situação normalizada de Terra da União na área desmatada, atribuindo cada IRU ativo à situação dominante por área de sobreposição? | WITH anos_recentes AS (
SELECT ano_desmatamento
FROM (
SELECT DISTINCT fd.ano_desmatamento::int AS ano_desmatamento
FROM analise_dados.fato_desmatamento fd
ORDER BY 1 DESC
LIMIT 3
) x
),
iru_ativos_desmat AS (
SELECT
fd.cod_imovel,
SUM(fd.area_desmatada) ... | expert | [
"geoespacial",
"terra_indigena",
"geografico"
] | false | false | true |
environmental_registry_benchmark_083 | Entre os estados com pelo menos 20 IRU ativos sobrepostos a TI, qual tem a maior fração de imóveis que também registraram desmatamento em algum dos 3 anos mais recentes da base? | WITH limites AS (
SELECT
MAX(ano_desmatamento) AS max_ano
FROM analise_dados.fato_desmatamento
),
recent_desmat AS (
SELECT DISTINCT
fd.cod_imovel
FROM analise_dados.fato_desmatamento fd
CROSS JOIN limites l
WHERE
fd.ano_desmatamento >= l.max_ano - 2
),
ti_imoveis AS (
... | expert | [
"geoespacial",
"terra_indigena",
"sobreposicao",
"geografico"
] | false | false | true |
environmental_registry_benchmark_084 | Entre os municípios com pelo menos 100 IRU ativos, qual tem a maior participação da área desmatada acumulada concentrada em IRU ativos que possuem sobreposição com TI? | WITH imoveis_ti AS (
SELECT DISTINCT
cod_imovel
FROM analise_dados.fato_sobreposicao_terra_indigena
),
desmat_por_imovel AS (
SELECT
cod_imovel,
SUM(area_desmatada) AS area_desmatada_total_ha
FROM analise_dados.fato_desmatamento
GROUP BY
cod_imovel
),
municipios_val... | expert | [
"geoespacial",
"terra_indigena",
"geografico"
] | false | false | true |
environmental_registry_benchmark_085 | Considerando apenas o melhor vínculo CAR de cada parcela SIGEF registrada, qual estado tem o maior gap absoluto entre a média ponderada por área e a média simples do índice de Jaccard? | WITH melhor_vinculo AS (
SELECT
fs.parcela_codigo,
fs.cod_imovel,
fs.indice_jaccard,
ds.area_hectares,
ROW_NUMBER() OVER (
PARTITION BY fs.parcela_codigo
ORDER BY
fs.indice_jaccard DESC NULLS LAST,
fs.area_sigef_car DESC... | expert | [
"terra_indigena",
"imovel",
"geoespacial"
] | false | false | false |
environmental_registry_benchmark_086 | Encontre os 20 imóveis IRU ativos mais paradoxais e retorne as colunas:
- sigla_uf
- cod_imovel
- max_pct_uc
- max_jaccard
- area_desmat_total_ha
- mediana_desmatamento_uf
- score_paradoxo
Considere apenas sobreposição com Unidade de Conservação não-APA e imóveis com similaridade SIGEF. O desmatamento deve ser o acumu... | WITH imoveis_iru_ativos AS (
SELECT
di.cod_imovel,
di.cod_uf
FROM analise_dados.dim_imovel di
WHERE di.ind_tipo_imovel = 'IRU'
AND di.ind_status_imovel = 'AT'
),
desmatamento_acumulado AS (
SELECT
fd.cod_imovel,
SUM(fd.area_desmatada) AS desmatamento_total_ha
FROM analise_dados.fato_desmat... | expert | [
"imovel",
"geoespacial"
] | true | false | true |
environmental_registry_benchmark_087 | Considerando apenas os imóveis rurais que possuem pelo menos um embargo, e definindo a severidade de cada imóvel como o maior valor de percent_car_embargos entre todos os seus embargos (MAX(percent_car_embargos) por cod_imovel), calcule, para cada UF, qual percentual da soma da area_imovel pertence aos imóveis que estã... | WITH base AS (
SELECT
di.cod_imovel,
di.cod_uf,
di.area_imovel,
MAX(fse.percent_car_embargos) AS max_percent_emb
FROM analise_dados.dim_imovel di
JOIN analise_dados.fato_sobreposicao_embargo fse
ON fse.cod_imovel = di.cod_imovel
WHERE
di.ind_tipo_imovel = ... | expert | [
"unidade_conservacao",
"geoespacial"
] | false | false | true |
environmental_registry_benchmark_088 | Quais são as 15 Terras Indígenas regularizadas com maior razão invasão/área (soma de area_ti_car sobre area_ti_total), considerando apenas imóveis IRU ativos? | SELECT
ti.terrai_nom,
-- ROUND(ti.area_ti_total::numeric, 2) AS area_ti_total_ha,
-- ROUND(SUM(s.area_ti_car), 2) AS area_invasao_hectares,
ROUND(
SUM(s.area_ti_car) / NULLIF(ti.area_ti_total::numeric, 0),
4
) AS razao_invasao_area
FROM analise_dados.fato_sobreposicao_terra_indigena s
JOIN analise_dad... | expert | [
"terra_indigena",
"geoespacial"
] | false | false | true |
environmental_registry_benchmark_089 | Selecione as maiores cidades em área de cada região do Brasil. Em seguida, calcule o baricentro do polígono formado pelos centroides dessas cidades. Por fim, informe o nome da cidade onde esse baricentro está localizado, juntamente com o estado (nome) e a quantidade de CARs. | WITH municipio_regiao AS (
SELECT
m.cod_mun,
m.mun_nome,
m.cod_uf,
m.geo_mun,
CASE (m.cod_uf / 10)
WHEN 1 THEN 'Norte'
WHEN 2 THEN 'Nordeste'
WHEN 3 THEN 'Sudeste'
WHEN 4 THEN 'Sul'
WHEN 5 THEN 'Centro-Oeste'
... | expert | [
"desmatamento",
"sobreposicao",
"imovel"
] | false | false | true |
environmental_registry_benchmark_090 | Para cada ano de desmatamento no bioma Amazônia, calcule o **centroide geográfico ponderado pela área desmatada** — ou seja, a média ponderada das coordenadas `latitude_desmatamento` e `longitude_desmatamento`, usando `area_desmatada` como peso. Em seguida, identifique o **município cujo centroide geométrico é mais pró... | WITH desmatamento_amazonia_ano AS (
SELECT
CAST(ano_desmatamento AS integer) AS ano,
SUM(area_desmatada) AS area_total_desmatada_ha,
SUM(latitude_desmatamento * area_desmatada)
/ NULLIF(SUM(area_desmatada), 0) AS latitude_centroide_ponderado,
SUM(longitude_desmatamento * ... | expert | [
"terra_indigena",
"unidade_conservacao",
"geoespacial"
] | false | false | false |
environmental_registry_benchmark_106 | Em Ouro Branco, a proporção de imóveis grandes é alta ou baixa? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_107 | Viçosa ou Triunfo: onde os imóveis ativos ocupam mais área no total? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_108 | Jussara tem muito CAR com embargo ou é só impressão? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_109 | Se eu olhar só os imóveis suspensos, Nova Olinda aparece pior que Novo Horizonte? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_110 | Em Cantagalo, qual é o tamanho do maior imóvel rural? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_111 | Belém tem mais CAR ativo ou mais CAR pendente? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_112 | Entre Boa Esperança, Mundo Novo e Santa Cruz, qual município parece mais pressionado por embargo? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_113 | Estou tentando lembrar se Cachoeira Dourada tinha muito CAR; consegue me passar o total sem abrir os detalhes? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_114 | Qual Santa Inês fica mais perto de Bom Jardim pelos centroides? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
environmental_registry_benchmark_115 | São Francisco lidera em área média de imóvel ou não? | clarification | fácil | [
"municipality_name",
"homonym"
] | false | false | false |
Environmental Registry Test Set
This dataset is the anonymized primary benchmark used for evaluating agentic Portuguese Text-to-SQL over a real PostgreSQL/PostGIS environmental-registry database. The underlying production database is not released, but the benchmark metadata and gold labels are provided for transparency and comparison.
Code and reproducibility repository:
https://github.com/Boakpe/distilled-slms-for-text-to-sql-pt-br
Related collection:
https://huggingface.co/collections/Boakpe/distilled-slms-for-text-to-sql-pt-br
Dataset Summary
- Rows: 180
- Split:
test - SQL questions: 90
- Clarification questions: 45
- Unanswerable questions: 45
- SQL difficulty split: 20 easy, 30 medium, 30 hard, 10 expert
- Language: Brazilian Portuguese
- Database type: PostgreSQL/PostGIS environmental-registry database
The primary schema contains 19 tables and covers rural properties, municipalities, Indigenous Lands, conservation units, environmental embargoes, settlements, quilombola territories, federal public lands, deforestation events, and spatial-overlap facts.
Columns
id: benchmark identifier.pergunta: natural-language question in Portuguese.sql: gold SQL for SQL questions, or terminal label such asclarification/unanswerablefor non-SQL questions.dificuldade: SQL difficulty label.categorias: topic labels.order_matters: whether row order is semantically required.num_column_matters: whether exact column count is required.num_row_matters: whether exact row count is required.
Evaluation Design
The benchmark combines:
- SQL generation.
- Ambiguity detection through clarification questions.
- Unanswerability detection.
- PostGIS/geospatial reasoning.
- Temporal filters, joins, aggregations, and domain-specific value grounding.
SQL evaluation uses execution comparison rather than exact SQL-string match. The reported primary metric is relaxed execution accuracy, with strict execution accuracy also reported as a diagnostic.
Reported Results
Primary environmental-registry benchmark, Pass@1:
| Model | Overall | Strict SQL | Relaxed SQL | Non-SQL | Clarification | Unanswerable |
|---|---|---|---|---|---|---|
| DeepSeek V4 Pro | 86.7 | 44.4 | 83.3 | 90.0 | 93.3 | 86.7 |
| GLM 5.1 | 84.4 | 44.4 | 80.0 | 88.9 | 86.7 | 91.1 |
| Qwen3-4B-Thinking FT | 78.9 | 34.4 | 70.0 | 87.8 | 86.7 | 88.9 |
| Qwen3.5-27B-Q3_K_M teacher | 75.0 | 40.0 | 70.0 | 80.0 | 75.6 | 84.4 |
| Qwen3-4B-Thinking-2507 base | 56.1 | 28.9 | 36.7 | 75.6 | 71.1 | 80.0 |
Fine-tuned model Pass@K:
| Setting | Overall | Relaxed SQL | Non-SQL |
|---|---|---|---|
| Pass@1 | 78.9 | 70.0 | 87.8 |
| Pass@5 | 91.7 | 87.8 | 95.6 |
License
Apache 2.0.
- Downloads last month
- 27