I have a table called movie_cast. This table already has duplicate values(#114). act_id, mov_id are foreign keys. And I’ve created a trigger on movie_cast table called trg1. Although the trigger is been created but after execution it shows some errors My task is: I want to allow entries in this table i.…
Tag: sql
How to fetch all rows where an array contains any of the fields array elements
I have a table that has a column video_ids, it is of a bigint[] type. I would like to find all the rows that have any of the elements from the array passed in a select statement. So, if I have a row that has a video_ids field that looks like this: I would like to fetch it if I
Sql function find date difference between two consecutive rows per group
I am working on clinical data to find total sessions for patients by finding date difference. I can achieve this using Python but power bi does not support that script. So I needed help to do this in SQL. I am basic level user of SQL so have no idea how to start for this. Below is raw data PatientID
SQL to generate %, n and N from the datatable
I seek your help in generating a summary query result as %, n (numerator), and N (Denominator) out of a variable in the dataset for each underlying category: e.g: data sr.no. is_healthy 1 yes 2 no 3 yes 4 no 5 yes 6 yes 7 no 8 yes 9 no 10 yes I expect the following as a summary result
Remove “” from string or in SQL varchar
Is it even possible to return value of string without the ” ” ? I have the following string: Chb = “NOT”; Now i either want to remove the “” in C# or SQL. so i want to have either Chb = NOT in C# ,or i want to remove the ‘ ‘ in SQL that i get in @Chb
SQL Where clause order
I have this SQL query: It runs fine and displays the expected result without the WHERE line, but I do need to filter the resultant data as that would imply. The error I’m getting is Invalid Column Name ‘FileCount’ after the WHERE keyword. I’ve been reading around and I can’t find…
Create custom groups on columns and count another column in sql
I’m using sql server and I have a table named Table that looks like this. SenderId ReciverId ItemCount 1 2 5 1 4 3 1 6 4 2 1 2 2 5 6 3 1 1 4 3 7 4 5 4 5 2 6 5 4 2 5 6 6 6 4 3 I want to make groups of
Import specific values from csv files to column of existing table
I am trying to figure out how to create a query/tsql that can import values from csv file to existing table. This is example how few records of csv looks like: And my existing table in SQL Employee table All columns already have values except SupervisorId (supervisorId is a foreign key that points at main key…
MySQL or MariaDB spread Date range in single row into multiple series of rows
Example tables are below, and example rows below, What I want to get is convert table above to below so that I can join using each date in range. Is there any way to extend date range in single row to series of Date row? Answer MariaDB 10.2+ or MySQL 8+ needed.
SQL query to filter columns
I have a question regarding the SQL query. I have this table shown below Region Rep Item Quebec Jones Pencil Ontario Kivell Binder Ontario Jardine Pencil Ontario Gill Pen Alberta Sorvino Pencil Quebec Jones Binder Ontario Andrews Pencil Ontario Jardine Pencil Alberta Thompson Pencil Quebec Jones Binder Ontari…