SQL lite
SQL lite
CREATE
CREATE TABLE table_name ... Creates a new table
TABLE
INSERT INSERT INTO table_name ... Used to insert new data in the table
SELECT SELECT * FROM ... Retrieves all the columns from a table
DELETE DELETE FROM table_name Deletes all the rows from the table
DROP DROP TABLE table_name Deletes the table from the database
ALTER ALTER TABLE table_name ... Used to add, delete or modify columns
DISTINCT SELECT DISTINCT col, ... Gets the unique values of given colum
GROUP BY GROUP BY col ... Groups the rows that have same values
Operators
Operators How to Use It Functionality
NOT WHERE NOT col = 'apple' Retrieves the rows if the condition(s) is NOT TRUE
WHERE col BETWEEN 3 Retrieves the rows if the column value is present bet
BETWEEN
AND 5 the given values
Functions
SELECT COUNT(col)
COUNT Counts the number of values in the given column
...
SUM SELECT SUM(col) ... Adds all the values of given column
MIN SELECT MIN(col) ... Gets the minimum value of given column
MAX SELECT MAX(col) ... Gets the maximum value of given column
AVG SELECT AVG(col) ... Gets the average of the values present in the given column
Extracts the year from the column value in string format. Sim
strftime() strftime("%Y", col) ...
month, day, week of the day and many.
CAST(col AS
CAST() Converts the value to the given datatype
datatype) ...
FLOOR() FLOOR(col) Rounds a number to the nearest integer below its current v
Functions How to Use It Functionality
CEIL() CEIL (col) Rounds a number to the nearest integer above its current v