0Pricing
Neo4j Graph Database Fundamentals · 강의

결과 필터링 및 정렬

WHERE 및 ORDER BY 절을 사용하여 쿼리 결과를 정제하고 필요한 데이터를 정확하게 가져옵니다.

결과 필터링 및 정렬은(는) CoddyKit의 무료 Neo4j Graph Database Fundamentals 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Neo4j Graph Database Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Neo4j Graph Database Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Refine Your Graph Queries

When working with large graphs, you often need to find very specific information or present it in a particular order.

  • Filtering helps you narrow down results to only what's relevant.
  • Ordering helps you sort your results for better readability or analysis.

In this lesson, we'll master the WHERE and ORDER BY clauses in Cypher.

Filter Results with WHERE

The WHERE clause is used to filter patterns or properties based on specific conditions. It typically comes after a MATCH clause.

Think of it like saying: "Find me all people, WHERE their birth year is 1970."

MATCH (p:Person)
WHERE p.born = 1970
RETURN p.name AS Name, p.born AS BornYear

Comparison Operators

You can use various comparison operators in your WHERE clause:

  • = (equal to)
  • <> (not equal to)
  • > (greater than)
  • < (less than)
  • >= (greater than or equal to)
  • <= (less than or equal to)

Let's find movies released after the year 2000.

MATCH (m:Movie)
WHERE m.released > 2000
RETURN m.title AS MovieTitle, m.released AS ReleaseYear

Logical Operators (AND, OR)

Combine multiple conditions using logical operators:

  • AND: Both conditions must be true.
  • OR: At least one condition must be true.
  • XOR: Exactly one condition must be true.
  • NOT: Negates a condition.

Find people born between 1970 and 1980 (inclusive).

MATCH (p:Person)
WHERE p.born >= 1970 AND p.born <= 1980
RETURN p.name AS Name, p.born AS BornYear

String and List Operators

Cypher offers powerful operators for string matching and list containment:

  • CONTAINS, STARTS WITH, ENDS WITH for partial string matches.
  • IN to check if a property value is within a list of values.

Let's find specific actors by name using IN.

MATCH (p:Person)
WHERE p.name IN ['Tom Hanks', 'Keanu Reeves', 'Carrie-Anne Moss']
RETURN p.name AS ActorName

Sort Your Results with ORDER BY

The ORDER BY clause sorts your query results. It comes after RETURN (or WITH).

By default, results are sorted in ascending order (smallest to largest, A-Z).

MATCH (p:Person)
RETURN p.name AS ActorName
ORDER BY ActorName

Ascending & Descending Order

You can explicitly specify the sort direction:

  • ASC: Ascending (A-Z, 0-9). This is the default.
  • DESC: Descending (Z-A, 9-0).

Let's sort movies by their release year, from newest to oldest.

MATCH (m:Movie)
RETURN m.title AS MovieTitle, m.released AS ReleaseYear
ORDER BY ReleaseYear DESC

Multi-Level Sorting

You can sort by multiple properties. The order in which you list them in ORDER BY matters.

Cypher will first sort by the first property, then by the second for any ties in the first, and so on.

Sort people by birth year (ascending), and then by name (ascending) for those born in the same year.

MATCH (p:Person)
RETURN p.born AS BornYear, p.name AS ActorName
ORDER BY BornYear ASC, ActorName ASC

Putting it All Together

A typical Cypher query flow often involves:

  1. MATCH: Find the graph pattern.
  2. WHERE: Filter the matched patterns.
  3. RETURN: Select the data you want.
  4. ORDER BY: Sort the returned data.

Find actors born before 1970, order them by name (descending), then by the movie title they acted in (ascending).

MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE p.born < 1970
RETURN p.name AS Actor, m.title AS Movie, p.born AS BornYear
ORDER BY Actor DESC, Movie ASC

Filter & Order Challenge

Which Cypher query correctly finds movies released after 1999 and orders them by title in descending order?

Recap: Refined Queries

Great job! You've learned how to precisely control your Cypher query results:

  • The WHERE clause filters data based on conditions.
  • The ORDER BY clause sorts your results in ascending or descending order.
  • You can combine these with comparison, logical, and string/list operators for powerful filtering.

Next, we'll explore how to summarize and reshape your data with Aggregation and Projections!

자주 묻는 질문

“결과 필터링 및 정렬” 강의는 무료인가요?

네 — “결과 필터링 및 정렬” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Neo4j Graph Database Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Neo4j Graph Database Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.

“결과 필터링 및 정렬”에서 뭘 배우나요?

WHERE 및 ORDER BY 절을 사용하여 쿼리 결과를 정제하고 필요한 데이터를 정확하게 가져옵니다. 브라우저에서 직접 실행하는 실습 코드로 Neo4j Graph Database Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Neo4j Graph Database Fundamentals을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Neo4j Graph Database Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“결과 필터링 및 정렬” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Neo4j Graph Database Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Neo4j Graph Database Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 결과 필터링 및 정렬
  2. 집계 및 프로젝션
  3. 그래프 데이터 업데이트 및 삭제
  4. WITH와 UNION으로 질의 결합하기
← Neo4j Graph Database Fundamentals(으)로 돌아가기