Category "sql"

Match any letter in a string

Table flights: ID Path 1 NZ:EU 2 JP:CA SELECT path FROM flights WHERE path ILIKE '%' || 'jpca' || '%' Above query isn't working, it needs to retu

PostgreSQL timescale - How to sort rows by time and id?

I have data in my timescale database. If we only look at the "time", everything is fine. But if we look at the "id" we can see that 152 and 153 numbers didn't s

Improving the running time of SQL query

Assume the query below take a long time to run. To improve the running time of this SQL query, which of the options below are the best way to do so? SELECT Name

SQL inner join performance data duplicate

table -- > qt qstnId tagId 1 1 1 2 2 3 2 4 2 2 table --> question qid 1 2 qid is primary key and qstnId is Fk now when i'm running query --> mysql&

How to get what percentage of total users joined what number of meetings in PostgreSQL?

There are two tables, one is called "user_preference" that contains all users: id | firstname | lastname | email | And "match" which combines users with meetu

Syntax error to combine left join and select

I'm getting a syntax error at Left Join. So in trying to combine the two, i used the left join and the brackets. I'm not sure where the problem is: SELECT DISTI

Aggregate dynamic columns in SQL Server

I have a narrow table containing unique key and source data Unique_Key System 1 IT 1 ACCOUNTS 1 PAYROLL 2 IT 2 PAYROLL 3 IT 4 HR 5 PAYROLL I want to be able t

calculate each in and out duration for an id

I've data like below Id date time type 1 01-01-2022 08:00 in 1 01-01-2022 11:30 out 1 01-01-2022 11:35 out 1 01-01-2022 12:45 in 1 01-01-2022 17:30 out 1 01-01

Join 4 tables across 2 databases - Getting duplicates

Objective: Pull report usage statistics from MS SSRS ReportServer database. Then, link to another table in a separate database (same server) to pull in employee

How to apply max function in a join query?

I am new to SQL Server, I have 3 tables consider an employee table empid name location 1 abc USA 2 efg UK Another table named location-table location holida

How to get max value from a MySQL Database

I have an MYSQL database table of student info and their test scores per subject and I am trying to fetch each student's highest score in all subjects using the

Interpolating variables in json string

I am using the code below to create a function with variables that updates a jsonb column with a json object or create it if it doesn't exist - With help from

Stored procedure sometimes takes a long time to execute query in SQL Server

I have strange issue and I am getting more confused about this. I am using UWP on the .NET framework and using SQL Server as database. The problem is my applica

Pyspark how to join common columns values to a list value

i am trying to join columns values to a list of values df1= name | department| state | id| -----+-----------+-------+---+ James|Sales |NY |101 Maria|F

SQL statement: SELECT data based on a condition

I want to base my select query on a condition so it is something like: --THE LOGIC TO BE IMPLEMENTED IF ( SELECT OrderPlacementDate from SellOrders WHERE SellOr

How show mysql query without NULL?

How show mysql query without NULL? I want to show my quary where "LAG(title) OVER(PARTITION BY emp_no)" IS NOT NULL, I need only titles.emp_no = "LAG(title) OV

MySQL OperationalError when deleting from DataJoint table after restricting with its part table: "You can't specify target table : 'part_table'"

Using DataJoint Python (0.12.9) on Ubuntu with MySQL 5.7 . Am running into an error with what I believed to be a fairly standard operation. Have a table named T

MySQL OperationalError when deleting from DataJoint table after restricting with its part table: "You can't specify target table : 'part_table'"

Using DataJoint Python (0.12.9) on Ubuntu with MySQL 5.7 . Am running into an error with what I believed to be a fairly standard operation. Have a table named T

Sequelize how to return result as a 2D array instead of array of objects?

I am using Sequelize query() method as follows: const sequelize = new Sequelize(...); ... // IMPORTANT: No changed allowed on this query const queryFromUser = "

"Illegal argument to function" in Postgres when doing select on a view with pgp_sym_decrypt() expression

I am using pg_sym_decrypt/encrypt to decrypt/encrypt some of the fields in my table. Decryption happens on select in a separate EntityComputed view that has a o