Why does it display the power field several times?

I enter that code, but it doesn’t work properly and it shows the power several times image Image >Solution : This seems to be happening because you have 3 products that have category id as ‘3’ and that category name I guess is ‘Power’. So, when you are selecting all the categories where each category… Read More Why does it display the power field several times?

I want to find max lenght of string from a tabe in SQLite

SELECT MAX(SELECT MAX(LENGTH(`name`)) count FROM `student_info` UNION SELECT MAX(LENGTH(`address`)) count FROM `student_info` UNION SELECT MAX(LENGTH(`class`)) count FROM `student_info` UNION SELECT MAX(LENGTH(`roll`)) count FROM `student_info` UNION SELECT MAX(LENGTH(`subject`)) count FROM `student_info`) FROM `student_info` by using similar type of query i want to find one max value of string so i can manage table properly. what is… Read More I want to find max lenght of string from a tabe in SQLite

Counting distinct values across columns using sqlite3 in python

I’m trying to count distinct values across columns using sqlite3 in python but cant seem to get the correct results. Am only able to get the count of distinct values in 1 column. I’ve create a database and imported the csv file as a table conn = sqlite3.connect(‘test.db’) curr = conn.cursor() curr.execute(‘DROP TABLE IF EXISTS… Read More Counting distinct values across columns using sqlite3 in python

FULL OUTER JOIN emulation and aggregate function (e.g. SUM)

Let’s imagine I have two sqlite tables: CREATE TABLE T_A (year_A INT, amount_A DOUBLE); and CREATE TABLE T_B (year_B INT, amount_B DOUBLE); Those tables contain data below: table T_A year_A | amount_A ———————- 2020 | 100.0 2020 | 200.0 2021 | 300.0 2021 | 400.0 table T_B year_B | amount_B ———————- 2021 | 1000.0 2021… Read More FULL OUTER JOIN emulation and aggregate function (e.g. SUM)

HOW CAN I CORRECT THIS SQLITE SYNTAX ERROR

IN MY EMPLOYEE TABLE COLUMN "HIREDATE" HAS (DATETIME) FORMAT AND I AM GETTING ERROR WHEN I TRY RETRIEVE THE DATA BY THIS QUERY BELOW: SELECT FirstName, HireDate FROM employees WHERE HireDate (‘2002-08-14 00:00:00”) I AM GETTING AN ERROR IN SQLITE. Execution finished with errors. Result: unrecognized token: "’2002-08-14 00:00:00”) " At line 1: SELECT FirstName,… Read More HOW CAN I CORRECT THIS SQLITE SYNTAX ERROR

how to send parameters with f-Strings in a sqllite query python

how can i send a parameter to a query this is my code import pandas as pd import sqlite3 def query_brand(filter): sql_query = pd.read_sql(f’SELECT * FROM ps_lss_brands WHERE label = {filter}’, self.conn_brand) df = pd.DataFrame(sql_query, columns = [‘id_brand’, ‘label’]) # print(df["id_brand"][0]) print(df) query_brand("ACURA") this the error that i get pandas.errors.DatabaseError: Execution failed on sql ‘SELECT… Read More how to send parameters with f-Strings in a sqllite query python