I have a table myTable that looks like this: +——-+——-+——–+————+ | Id | Agent | Qualif | Date | +——-+——-+——–+————+ | 1 | A | Q1 | 2019-05-…
Tag: sql
How to write a WHERE clause for NULL value in ARRAY type column?
I created a table which contains a column of string ARRAY type as: CREATE TABLE test ( id integer NOT NULL, list text[] COLLATE pg_catalog.”default”, CONSTRAINT test_pkey PRIMARY KEY (id) …
detect cycles in a graph in SQL using recursive common table expression
Given a directed graph having a cycle, how do you detect and list the cycle using only standard SQL ? input = graph edges and a root node from which we compute the transitive closure. Output = …
SQL query for column numbers
I have a table with information like : With these 2 columns I need to pull a column like “New Column” which is basically serial numbers of pages for each order. I tried ROW_NUMBER() OVER(ORDER BY …
How to send varying number of variables in R function to be used by sql query
I’m writing a R code which will pull data from a data frame using sql query. My function looks like formatData =function(compe1,compe2) { query=paste(“Select A.month as month,sales_comp1,salse_comp2 …
Need to select 2 most recent dates for 2 id’s
I need to return 2 most recent dates for each client id, i have 12345 and 112233 and for each of them i need to create a function which supposed to return to me this id | client_id | created …
Calculate the numbers of week names
I tried to edit but I have not knowledge about the number of weeks: declare @from datetime= ‘2019-06-01’ declare @to datetime = ‘2019-06-19’ select datediff(day, -3, @to)/7-datediff(day, -2, @from)…
How to display each row from sql in a table in php
I have a table within a modal. I want the table to display the top 3 goalscorers from a football game. The following code is not returning the table. Any help greatly appreciated!. At present I am …
Pulling another row if it meets criteria from the first pulled row
Need to compare some accounts, which some people have two of, an admin account and a regular account. These admin accounts list their regular account as their manager and all of the admin accounts …
How can I solve a performance issue in my stored procedure?
I have a performance problem with a stored procedure. Because when I check my benchmark’s result I realized that “MatchxxxReferencesByIds” has ‘240.25’ ms Average LastElapsedTimeInSecond. How can I improve my procedure? Answer Based on the execution plan of the stored procedure, …