Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Points
Linestrings
Polygons
Summary

Instruction

Perfect! The next function we'll get to know is ST_Npoints. It returns the number of points in a given linestring. Take a look at how it's used:

SELECT 
  id,
  ST_Npoints(course) 
FROM sf_selected_railways 
ORDER BY 2 DESC;

The query above will show the number of points in each railway and order them in descending order, from greatest to least number of points.

Exercise

So far, we've only used spatial functions in the SELECT clause, but that's not the only option. You can also put them in other places, such as the WHERE clause. Let's try that now.

Show the total number of bicycle routes in sf_bicycle_routes that have more than 100 points.

Stuck? Here's a hint!

Use the following condition:

WHERE ST_NPoints(course) > 100
You'll also need COUNT(*).