Category "sql"

updating sql with php

I need to be able to update my sql table from open to close task. I already wrote code for this but it is not working properly. On the modal it shows 2 'continu

Druid generate missing records

I have a data table in druid and which has missing rows and I want to fill them by generating the missing timestamps and adding the precedent row value. This is

How to find time duration of ride given its starting time and ending time by using sql query

The start_on column in RIDE table is starting date and time for each ride and ends_on column is ending date and time of ride. i have to fetch the ride whose tr

Trying to separate sql DB values from each other

function absent() { const absent_date = new Date(); const absent_days = absent_date.getDay(); console.log("days", absent_days); let absent_remo

Sqlite - Return rows where some values are different

I have a large table a SQLite database of student exam results. Students often resit failed exams and subsequently pass them as shown with student 10001 below.

Storing a list of codes into a variable in Oracle SQL [duplicate]

There's a way to store a set of codes into a variable in Oracle SQL? I have these codes and I'll need to use them in different parts of my que

ORA-00936: missing expression - SQL pivot

Getting the above error in the IN statement. Can you anyone help? ORA-00936: missing expression 00936. 00000 - "missing expression" *Cause: *Action: Error

SUM UP two columns and then find the find MAX value in SQL Server

I am working with Microsoft SQL Server and want to find E_ID and E_Name where T1+T2 has the MAX value. I have two steps to reach the necessary result: Find the

SQL Server: Limit filling NULL values up to row with specific text

I have a CTE on which i am filling null values with the previous value before row 100 available by using the following script SELECT [YearMonth],grp, CASE WHEN

XML data at level 3/4 getting NULLs

I got my source data XML into snowflake stage tables. It's quite a complex XML document data for each record in the table. I got some of the elements using flat

Update date format in jsonb object in postgreSQL

Postgres table have one column as JSONB with below format { "steps": [ { "step": "Building", "status": "Complete", "end_date": "03/08/20

How can I apply a condition to multiple rows using SQL? CASE WHEN / PARTITION OVER

I am trying to create a column that shows Yes or No based on a set of conditions. If the conditions are met, then 'Yes' would apply to every row in the group (e

Function does not exist in PostgreSQL

I have this Postgres code CREATE PROCEDURE adjust_available(patientBed UUID) LANGUAGE SQL AS $$ UPDATE bed SET available = false WHERE bed.id = pati

TypeORM Select Specific Column Only

I'm using TypeORM. Via Repository/Entity pattern and findOneOrFail, I want to select a specific column (isBusiness) only for my results. this.userProfile.findOn

Split Hours into Multiple Months using SQL

CREATE TABLE EventLog ( EventID INT , EventName VARCHAR(50) NOT NULL , EventStartDateTime DATETIME NOT NULL , EventEndDateTime DATETIME NULL ) INSERT IN

R's ceiling_date equivalent in SQL

I want to implement R's ceiling_date fucntion in SQL (Postgresql). So I have dates in a column for everyday with corresponding sales and I want to accumulate th

What is the optimized/best way to retrieve data from two tables?

I have two tables: post table: |post_id | post_title | +--------+------------+ | 1 | Post 1 | | 2 | Post 2 | | 3 | Post 3 | post_cre

SQL tuple/lexicographic comparison with multiple directions

I need to return elements from a database query based on an inequality using the lexicographic ordering on multiple columns. As described in this question this

how to sum results of a calculated column

I'm trying to get the total duration of membership types (member&casual) another application of the same problem would be to get the total count of the popu

Overflow when looping through SQL-inserts for an ADODB.connection

I am trying to insert real-time data from a financial service provider into Excel, which can only be fetched with an Excel-plugin in blocks of roughly 100,000 v