年齢層の男女の集計値を取得しようとしています。例:25歳未満の男性と女性の数。
MATCH (m:user)-[:gender]->(male:gender {type:"male"})
With m AS m25
where tofloat(m25.birthday) < (timestamp()-788923800000)
RETURN count(m25)
これをすべて1つのクエリ内で実行したいので、13〜25、26〜25などの男性と女性のカウントを取得します。コレクション関数は私の質問に答えているように見えるので頭を悩ませていますが、上記のコンテキストでそれらを適用する方法がわかりません。
どんな助けでもいただければ幸いです!
UNIONによって結合された一連のクエリを使用するか、一連のWITH句を使用してクエリをチェーンすることができます。
例えば
MATCH (m25:user)-[:gender]->(male:gender {type:"male"})
where tofloat(m25.birthday) < (timestamp()-788923800000)
RETURN count(m25)
UNION
MATCH (f25:user)-[:gender]->(female:gender {type:"female"})
where tofloat(f25.birthday) < (timestamp()-788923800000)
RETURN count(f25)
UNION
...
...または...
MATCH (m25:user)-[:gender]->(male:gender {type:"male"})
where tofloat(m25.birthday) < (timestamp()-788923800000)
WITH count(m25) AS male25
MATCH (f25:user)-[:gender]->(male:gender {type:"female"})
where tofloat(f25.birthday) < (timestamp()-788923800000)
WITH count(f25) AS female25, male25
...
等。
HTH
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加