SQL: Doing GROUP BY in CsvPath
dev.to·3d·
Discuss: DEV
📋CSV Processing
Preview
Report Post

Let’s look at how to create a simple GROUP BY report in CsvPath Framework’s tabular data validation language. Of all our examples, this is an easy one!

A GROUP BY query is straightforward. It selects rows and groups them according to one or more columns. The archetypal example is:

SELECT
dept,
role,
SUM(salary) total_salary
FROM    employee
GROUP BY dept, role

This query produces a result set with three columns. The first two are a unique combination of the dept and role columns and the third is a summation of the salaries in the rows with that combination of department and role.

For our example we’ll use FlightPath Data’s built-in examples because they are handy. Every time you create a project Fligh…

Similar Posts

Loading similar posts...