Category "sql"

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

The datetime columns in all the tables on SQL server have shifted by a few hours

I've created a few tables all of which had a column of datatype datetime. Recently, I think after the daylight savings adjustment, for some reason all the dates

postgreSQL - fill in blank date rows per ID

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

List all table origin columns for all views in Oracle database

Let's assume I have following tables: TABLE_A (ID; NAME; ...) TABLE_B (ID; NAME; TABLE_A_FK; ...) And I expose the table data through this view: SELECT a.id, a

How to get the partition column names for a table?

I have a table that is partitioned on one or more columns. I can do ... SHOW PARTITIONS table_db.table_1 which gives a list of all partitions like this, year=2

PHP array filled by a MySQL query [closed]

I need to fill multiple different arrays by using a MySQL query. This would have up to 16 different arrays. I want to specify each array with

Is the logic and the implementation of this query correct?

So i have a table that logs users using certain apps. It has the fields below id time app user server type (can be IN or OUT) So a user starts using a certain