I need to build a query to copy information in a column from one table to a column in another table. This is how the tables looks like: People: PersonId Name StatusId 1 John 2 Jenny 3 Steve …
Limit the results returned by MySQL join to 1
I’m doing a JOIN on two tables and the right side has multiple results for the ON clause: e.ID = ti.event_id. How do I limit the results returned by the join to 1? Sort of like LIMIT 1 events_detail …
How to fix Ora-01427 single-row subquery returns more than one row error?
I have query like this and it gives me single-row subquery returns more than one row error: SELECT COUNT(PERSONNEL_ID) FROM (SELECT DISTINCT * FROM CUSTOMERS) WHERE CUSTOMER_ID = (SELECT CUSTOMER_ID …
in Oracle database, how do I create a table of varchar2 type without length
for using it as a returning type in a function, I need to create a type at database level. I do it by typing the command : CREATE TYPE empno_tbl IS TABLE OF VARCHAR2(100); but this obliges me …
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 …
Join pandas dataframes based on different conditions
I´m using Pandas in Python and I’d like to join 2 dataframes. My first dataframe is: id var date 1 ABCD 2019-01-01 1 ABCD 2017-06-01 1 ABCD 2016-06-01 2 ABCD 2016-01-01 The dataframe I want to …