Skip to content

using what I think is a variable in a SQL statement

I am very new to SQL and think I have a simple problem but was unable to figure it out from other posts. I have the following code: INSERT INTO tblShortScores ( TradeNum, FilterNum, Rank, ScoreNum ) …

Sum different items in two different columns

I’d like to have two columns that show the sum of different items purchased. For example DB Name: Purchases CustomerID Shirt 123 Red 123 Red 123 Red 123 Blue 123 Blue The result I’d like to get …

How to order a group of rows by created_at?

My visits table looks like this: id name isp created_at 1 Jack Comcast 2021-03-13 01:00:00 2 Jack Comcast 2021-03-13 01:01:00 3 Tom Comcast 2021-03-13 01:02:00 4 Jill Amazon 2021-03-13 01:03:00 …

pyodbc sql statement does not accept nvarchar

I am connecting to SQL database using python. Using pyodbc driver for this. The connection is successful and working fine. My problem is when I write any SQL statement which involves any condition …

How to use IN clause with SQLParameters?

My function works perfectly if I provide one instance of ComputerName value. My question is how to modify SQL query so it could accept an array? I don’t believe creating a loop to query a database …