Skip to content

Tag: sqlite

How to get the most recent data from a table?

Here is the table that I have The question that I have for my query is “Using the most recent month of data available, what is the range of estimated home values across the nation?” Since my table is small, I know the recent date is 2020-06. So I wrote this code: And the result that I get is: Anot…

How to get the row index in SQLite3?

I have created a table that has a column of registration number as primary key. I have created row_id using row_number() that is ordered by the primary key. How can i search a registration number and get the row_id along with other information of that row? Answer If you have created the column row_id like: th…

Create a database in python where user inputs the data?

I would like the program to ask the user for information (i.e. age and name) and for this information to be put into the database. I have tried the following: The error that keeps appearing is: I have Python 3.7 and I work in spyder. Answer Try this, student_name is a string and should be enclosed in single q…

Updating Multiple Columns in sqlite3

I am wanting to update multiple columns in my ‘Class’ Table in sqlite. I do not know how to do this so I approached the same syntax as an ‘INSERT’ query however, I seem to be having the following syntax error: sqlite3.OperationalError: near “VALUES”: syntax error The line I…

Optimize SQLite Query using GROUP BY

I am trying to optimize my query which uses GROUP BY. But can’t it takes too long time. I have a virtual table which contains 3 columns: I want the group to be just as the query below, but it just takes a bit too long to run. For example I tried this first which works pretty good but still

How can I calculate percentages from total rows and status in sql?

I have a table that contains a list of templates and statuses that I am trying to calculate percentages on. My schema looks like the following: SQL SQL to Create DB Sample Data: What I’m trying to achieve: The query I have so far is the following: The problem I have is that my percentages return nothing…