Category "sql"

How to calculate difference between two dates in oracle 11g SQL

When I am trying to calculate the date difference by using datediff function it showing that invalid identifier. SELECT DATEDIFF(day,'2008-08-05','2008-06-05

Typeorm of sql query

This query works well on the database, however I'm not able to make it work by using typeorm createQueryBuilder. SELECT * FROM content INNER JOIN FreeTextTable

SQL Server after update trigger

I have a problem with this trigger. I would like it to update the requested information only to the row in question (the one I just updated) and not the entire

Extract data from JSON column

i want to extract a value from a json column. The schema is (- first level, -- second level): Column Name | Type | Mode event_params RECORD NULLABLE -key STRI

Bigquery keyword Remote is not supported

We are trying out the REMOTE functions within bigquery as per this guide. We created the CLOUD_RESOURCE using the following command : bq mk --connection --disp

SPARK SQL - case when then

I'm new to SPARK-SQL. Is there an equivalent to "CASE WHEN 'CONDITION' THEN 0 ELSE 1 END" in SPARK SQL ? select case when 1=1 then 1 else 0 end from table Tha

Qlikview - Insert a recno() for each change in a column

I have a table with Document Numbers and items. We have integrated our software to a third party accounting package. The import to the third party does not take

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

I have a column in a table that I want to use for an unique-index. My script should make the data unique by concat the id of a record, if the data of current re

ARRAY_AGG() grouped by another column's values

Here's my table like below p_no type name value ------------------------ 1 A Tomy 1 1 A Nick 2 1 B Tomy 3 1 B Nick 4 1

BigQuery insert values AS, assume nulls for missing columns

Imagine there is a table with 1000 columns. I want to add a row with values for 20 columns and assume NULLs for the rest. INSERT VALUES syntax can be used for t

Get unique values of a field and prints its length

Table Name: Worker, Fields : worker_id | first_name | last_name | department I have a table name worker and i wanted to write an SQL query that fetches the uni

check for any column contains provided values after group by

I have a data set like this. CREATE TABLE EntityItems ( Id INT NOT NULL, EnitityItemId INT NOT NULL, PRIMARY KEY (Id, EnitityItemId) ); INSERT INTO

Why use GTIDs in MySQL replication?

When it comes to database replication, what is the use of global transaction identifiers? Why do we need it to prevent concurrency across the servers? How is th

How to select columns with an even ID number?

I'm trying to solve the Hackerrank problem Weather Observation Station 3 which is stated below: I came up with the following solution: SELECT CITY FROM STAT

Teradata merge multiple records into single record

I want to merge multiple record into single record Ex: Input pdt status start_dt end_dt a Inactive 2022/02/02 2022/02/04 a Inctive 2022/02/05 2022/02/10 a Acti

Oracle SQL | Auto incremented ID is not incremented when an id is provided

I have following incrementing id: create table PATIENT ( PATIENTID INTEGER generated by default on null as identity ( start wit

Query the two cities in STATION with the shortest and longest CITY names, [closed]

Query: Query the 2 cities contained in STATION table with the shortest and longest CITY names, as well as their respective lengths (i.e.: numb

DB2 SQL Statement WHERE clause CASE WHEN in multiple conditions

This is what I am trying to do: SELECT id, name FROM users WHERE isActive=true (AND CASE WHEN {param} != null THEN name={param} ELSE null E

How to update record with the same data of existing record

How to update record many columns with the same data of existing record in the same table . For Example : id name m_value 1 moh 1000 2 jo 0

Conversion failed when converting the ****** value '******' to data type ******

I'm getting this error from SQL Server on SSMS 17 while running a giant query: Conversion failed when converting the ****** value '******' to data type ****