CSVSQL

SQL query on CSV file

Simple query

csvsql --query "select * from sales_100" ./sales_100.csv

with Limit

csvsql --query "select * from sales_100 limit 5" ./sales_100.csv

using MAX aggregate function

csvsql --query "select max(unitprice) from sales_100 limit 5" ./sales_100.csv

Use double quotes to handle columns that have Space in between them in csvsql

csvsql --query 'select distinct("Order Priority") from sales_100' ./sales_100.csv

Using Group By

csvsql --query "select country,region,count(*) from sales_100 group by country, region" ./sales_100.csv

using WildCards

csvsql --query "select * from sales_100 where region like 'A%' order by region desc" sales_100.csv