All In One Script
MENU

Select first row in each GROUP BY group?

by 1:11:00 AM
undefined
Select first row in each GROUP BY group? As the title suggests, I'd like to select the first row of each set of rows grouped with a GROUP BY. Specifically, if I've got a purchases table that looks like this: SELECT * FROM purchases; id | customer | total ---+----------+------ 1 | Joe | 5 2 | Sally | 3 3 | Joe | 2 4 | Sally | 1 I'd like to query for the id of the largest purchase (total) made by each customer. Something like this:

How to list the tables in an SQLite database file that was opened with ATTACH?

by 11:40:00 PM
undefined
How to list the tables in an SQLite database file that was opened with ATTACH? What SQL can be used to list the tables, and the rows within those tables in a SQLite database file - once I have attached it with the ATTACH command on the SQLite 3 command line tool? Answer: The .tables, and .schema "helper" functions don't look into ATTACHed databases: they just query the SQLITE_MASTER table for the "main" database. Consequently, if you used ATTACH some_file.db AS my_db; then you need to do SELECT name FROM

Instagram