Category "sql"

SQL query returns result multiple times

I'm pretty new to SQL and am trying to join some tables in SQL. I'm using SQLite3 and Pandas and have the following table structure: User | Measuremen

TSQL Subquery in from

I am attempting to do a subquery which should work but I am missing something in the syntex. I am trying: select * from (select * from (select *, row_number

ERD - Recursive relationship with two primary keys

I have a product table: Product (ID, Version) And I am having trouble creating a recursive table named "Update". this table should have a product ID and for eac

How do you use a JSON array in a "WHERE IN" clause in MariaDB

I am using MariaDB version 10.2 I have an array of GUIDs stored as JSON in a table and I want to select rows from another table where the ID matches any of the

org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "drop table if exists [*]user CASCADE "; expected "identifier"; SQL statement:

I've below data.sql file in my src/main/resources/data.sql file. I would like user tabel to be created from user.csv file. DROP TABLE IF EXISTS `USER` CASCADE;

Oracle SQL Trigger: After Update, Insert Rows into Another Table

I am trying to write a trigger on one table that is triggered when the quantity in stock = 0. It will then add a row to another table with the product_id and st

How can I display the header of columns of all tables within a SCHEMA

I would like to list out all the tables and column headers within a SCHEMA to be displayed in Rows within MySQL, I can't seem to find an answer online and would

Change Two Rows Into Two Columns

Oracle newbie here just trying to learn something. I have a query that returns two rows per ID: SELECT B1_ALT_ID, B1_CHECKLIST_COMMENT FROM PERMIT WHERE (B1_CHE

Make a Report that Can Edit another Report in APEX

I have multiple report pages. I am working on a system that stores a lot of data. Is it possible to have reports that are able to have column edited on two diff

Transpose results of a sql query

How to transpose this display. SeqNo Step Date By 1 Quoted 2018-03-01 Person1 2 Checked 2018-03-02 Person2 3 A

How to find the number of rows for all views in a schema?

Sometimes I have access to schemas with hundreds of views (when using the Snowflake Data Marketplace). How can I find the number of rows for each of these views

Grouping ranges of data

I have segmented linear data to identify the minimum and maximum begin and end values of each range, now I want to consolidate overlapping ranges. This is easy

How can I write a case sensitive WHERE CLAUSE in SQL Server?

Ok, this one has me stumped. I'm hoping it's not something stupid/obvious... I'm trying to fix addresses in a client database. I have a function that takes a

How to delete a record from database where all fields are the same to another?

I have two only records in a database table and I want to delete only one of them. The problem is that I don't have any primary key nor unique identifier, so ho

Are nested SQL queries atomic?

I have some micro service (almost) system where each program has its own port. Moreover, not all ports in the system are available. For simplicity, I decided to

How to reuse a computed value multiple times?

Basically I just want a simple way of finding the most recent date in a table, saving it as a variable, and reusing that variable in the same query. Right now t

How to pivot between current day and previous days

I'm using Access SQL I have data that looks like this:- dealdate value 17-Apr-22 267 18-Apr-22 274 I'm trying to make the data look like this (there will only

How to re-run Diesel migrations?

I'm using Diesel with PostgreSQL. I added my migrations, and they worked fine, outputting everything in the schema.rs file. Until I noticed that I was missing t

Using Pivot to remove duplicated results adding new columns

I have the following table [_teste_calendario_Table] and when "Monstrengo" has the same value, I'd like to make a pivot, adding new columns "De1", "Ate1", "Ven

How to use Knex object in other file?

How do I use the knex db object inside other files? For Example my index.js const app = require("express")(); const cors = require("cors"); const bodyParser