cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

I need to make a top 5 of canceled contracts in a query, but I also need to bring the rest, because I need to plot the top 5 most canceled contracts and I need to know the rest in a single return.

The top 5 i managed to do, I just can't take advantage of the same query to bring the rest.

MATCH(dca:DashboardCancelamentoAno)<-[:NIVEL_HIERARQUIA_CANCELADOS_ANO]-(dcm:DashboardCancelamentoMes)
MATCH(dcm)<-[:NIVEL_HIERARQUIA_CANCELADOS_MES]-(dbcd:DashboardCancelamentoDia)
MATCH(dbcd)<-[:NIVEL_HIERARQUIA_CANCELADOS_DIA]-(dce:DashboardCancelamentoExecucao)
WHERE dca.ano = 2021 AND dcm.mes = 8
AND dce.fornecedor IN ["BRADESCO","SulAmérica Saúde","CNU","AMIL","UNIMED-RIO"]
return dce.fornecedor as Fornecedor, count(dce) as forc order by forc desc

Comments
mdfrenchman
Graph Voyager

How does that limit to just the top 5? I don't see LIMIT 5 anywhere in there.

Are you arbitrarily filtering the top 5 using the IN clause?

Would like to help but need more information.

To use 2 queries, you can use LIMIT 5 for the top 5 (after order by). Then use SKIP 5 for the other query.

To use a single query, return the entire set and split it client side.

-Mike

Version history
Last update:
‎09-22-2021 08:25 AM
Updated by:
Contributors