Category "sql"

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

get max value of non duplicated records

Is it possible this? I have the following table: Col1 Col2 col3 code1 US 9 code1 0 5 code2 US 4 code2 0 11 code3 0 11 and I'm trying to get the higher col3 va

How to create / login to a user in CockroachDB

I have created a local cockroachDB using: cockroach sql --insecure and when I am trying to create a user using: create user 'name' with password 'password'; I

how to add contraint on table using view

I try to use View to create a constraint on a Mysql Table. I have one table with cinemas sessions and one other for tickets, the goal is we can't sell tickets w

SAS : Problem with put function in a proc sql

I'm trying to create a table using a sql procedure with a column in date9 format, however, despite the put function I use with the date9 parameter, my column is

Get all numbers 1-100 per ID even without data

I have a table which looks like this: ID money_earned days_since_start 1 1000 1 1 2000 2 1 3000 4 1 2000 5 2 1000 1 2 100 3 I want that rows, without a days_s

Cannot cast varbinary to varchar in presto

I have a column which is in varbinary. I tried select cast(msg as varchar) from table WHERE DATE(datestr) > CURRENT_DATE - INTERVAL '7' DAY which threw C

Converting HTML User Form input into .sql file that is in the same folder Using PHP (Question)

The reason why I am asking this question is because everyone seems to say to create a database using myphpadmin or mysql which i am having great trouble trying

TypeORM - how to reuse entities across many projects?

I've had a few project which is using this same database and entities. How to reuse entities across all of this projects? I don't want to copy all *.entity.ts f

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102 [closed]

I am receiving the error of SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102 i

Return Monthly Revenue based on a start and end dates

I am looking to create a query that would return the individual monthly revenue for the next 12 months. The revenue amounts are currently stored by projectid an