Category "sql"

Statistical Tests in R

I want to run Bonferroni P Adjusted Value Test on a stacked data set. This is my code: stat.2 <- stack.2 %>% group_by(modules) %>% t_test(values ~ phen

Can't SET variable in BigQuery | Error: Cannot coerce expression

I'm trying to set variable in order to make further operation. But when I set my first variable on line 2 ("SET(new_user)=( "), I get an error Query error: Can

Firebird query returns Buffer

This is my first time connecting to a Firebird database from Node JS. I'm using the "node-firebird" package. Everything seems to work fine. But I get these <

How can I store data from JS into a MySQL database

First things first, I'm new to the forum, anything I write that isn't concise or just flatt out adjective let me know! I'm developing an app that can retrieve d

How to Add Multiple JSON_BUILD_OBJECT entries to a JSON_AGG

I am using PostgreSQL 9.4 and I have a requirement to have an 'addresses' array which contains closed JSON objects for different types of address (residential a

How to generate a range of numbers between two numbers then duplicate entries from that range?

I would love some help with a query to expand an Access Table I'm working with. I need to generate a range between the min and max numbers and then duplicate th

SQL Moving window over two level of groupby

I have the following table of orders for users like the following: CREATE TABLE orders ( order_id UUID, user_id UUID, date date,

Is there a way to check that none of the rows in a grouping contain a value?

I have a query that looks like this: SELECT ordDetails.OrderId FROM orders.OrderDetail ordDetails WHERE ordDetails.Class <> 'O' GROUP BY ordDetails.

Displayed values are not what they should be

There are 2 tables ost_ticket and ost_ticket_action_history. create table ost_ticket( ticket_id int not null PRIMARY KEY, created timestamp, staff bool, statu

Creating A Stored Procedure That Truncates A Table With Foreign Keys

I would like to make a stored procedure in SSMS that will truncate a table that has foreign keys. Here is what I have right now but when I pass a table with for

MySQL dynamically find available reservations

I have a requirement to create a room reservation system with dynamic booking slots (a reservation can start at any time and last anywhere from 15 minutes up to

How do I combine YEAR and MONTH into a DATE?

I'm looking for an easier way to do this. My current code is written as below: CASE WHEN LENGTH(CAST (MTH AS VARCHAR(4))) = 1 THEN CAST(CAST (YR AS VARCH

PostgreSQL year, quarter calculator

Given a year and a quarter, a procedure should INSERT values into table tb_quarter, which is empty and have this structure: CREATE TABLE erp.tb_quarter (

Find the total amount for each day. Amount calculated from all previous days if day is not Monday

This was a question asked in a BI Engineer interview. I could not solve it and still scratching my head around it. Although, I used lag window function using ca

Selecting all rows from t1 join t2 on id and select the lowest value from t2 or null if not any

I have two tables, one holds some categories and the other holds players' records like so: Categories Times id Name id UserId MapId Categ

Digitalocean basic droplet for wordpress website showing database error every now and then

I have created a basic 5$ droplet with digital ocean to host a wordpress website. After installing the wordpress as soon a i login to the dashboard and start wo

SQL Over/Under Column Comparison

I am trying to pull rows where the Net_Qty is +/- 300 of the Order_Qty, but I think I might just be missing something with the syntax. SELECT DISTINCT o.Ord

Foreign key 'FK_NhanVien.....' references invalid table 'PhongBan". Why invalid?

Foreign key 'FK_NhanVien.....' references invalid table 'PhongBan". Why is it invalid? create table NhanVien( MaNV varchar(9) not null primary key foreign k

Check if value exists on one date missing on next

I have one table with below column Table I want to find missing nodes Missing node definition: node present on day and missing the next day will be missing node

MySQL Subtract Date Time and insert results into a new Column

I have a MySQL database, I use Heidi SQL to access it. The following columns are part of one of my tables: START_DATE START_TIME STOP_DATE STOP_TIME 01-10-202