Category "sql"

Deadlock on Select from table-valued parameter

I have this piece of code which acquires connection from EF Core DB context and executes select on the received data. var conn = _dbContext.Database.GetDbConnec

LARAVEL: How to fetch id dynamically in a query builder?

I want to join multiple tables in laravel with query builder. My problem is that my code only works if I specify the id myself that I want like this: $datauser

Calculating the mode/median/most frequent observation in categorical variables in SQL impala

I would like to calculate the mode/median or better, most frequent observation of a categorical variable within my query. E.g, if the variable has the following

How to parse json data in a column with Druid SQL?

I'm trying to parse json data in a column with Druid SQL in Superset SQL lab. My table looks like this: id json_scores 0 {"foo": 20, "bar": 10} 1 {"foo": 30, "

How do I backup a database with a stored procedure in SQL?

I'm trying to create a stored procedure that backs up a database, however whenever I execute it, the folder I'm trying to backup to remains empty. Here is my st

How to update a value in column based on value from other table in SQL server?

I have two tables match_score and match_condition I want to update table match_condition and set values of innings, first_4, etc. Here's the example in which I

Get first day of sequence SQL

I would like to get first day of continuous date sequence. Query is valid for one month. I am using SQL Server 2014. Table example: Id | VechicleISO | RideISO |

Updating foreign keys from data table to keys from new table? Without dozens of queries?

I am migrating some data. I have a table data which has quite a lot of columns to reference other tables. And those other tables are being changed and simplifie

Recursive View Message - Azure Data Bricks

Error : AnalysisException: Recursive view management_db.v_extract detected (cycle: management_db.v_extract -> management_db.v_extract) Query outisde of the v

Listing tables USED BY materialized view in PostgreSQL?

I've googled for it, both couldn't find an answer. How can I list tables used by materialized view (must not use the information_schema views) in PostgreSQL? Th

Rename MySQL table name safely in Flyway script

I'm going to rename a MySQL 8.0 table via Flyway SQL script: RENAME TABLE aaa TO bbb; and it's supposed to be run on env many times - but such the script is no

Postgresql argument placeholder in jsonpath expression

I try to pass argument $1 to jsonpath-expression: SELECT 1 FROM %s.orders AS O WHERE order_info @? '$.items[*] ? (@.ProductID == $1)' but it doesn't work. P

Need help - Divide by 0 error in window equation?

I have the query below and keep getting a divide by 0 error but I'm not sure how to add something to bypass that select x.year, x.month, x.period, coalesce(

How to use group by and ordery by with some operation in SQL? [closed]

I have two columns price and sold_count for the product table. How do write sql query to find the top 3 shops having highest Revenue (calculat

Solution add textbox in SQL as string in vb.net

What is the solution if you see the code below there is a value (2000) then I want to change it to textbox so I can custom value. Thanks jack Dim sql As String

YYYYWW format in SQL Redshift

My company recently migrated to Redshift from Redash recently and I'm having a hard time recreating the YEARWEEK() function available in MySQL but not in Redshi

SQL Server - Combine two select queries

I have two tables, Semester1 and Semester2. Semester1: StudentId SubjectId abc sub1 def sub1 ghi sub1 Semester2: StudentId SubjectId abc changedSub1 def sub1

Query Optimization, changing the queries in the loop into a single processing query

How do I optimize these queries to be one or two? The one in the loop to be one at least. $applicantIds = \DB::select()->from( 'applicants' )->where( 'cre

How to remove the first word from a large string

I want to remove the first word from a large string in SQL Server. Input string: 931078027 BP 16:20:0:13 25 BAG 'B' CLASS Desired output: BP 16:20:0:13 25 BAG

I want multiple servers processing data from a single database table

I have a single database table on a relational database. Data will be loaded into it. I then want to have multiple servers processing that data concurrently (I