Category "sql"

SQL query to get data if fields match or null if they dont

I need to get a list of users with their corresponding bed_id in case user has bed_id and fill with null if user doesn't have bed_id since there will always bee

If BULK INSERT fails because file does not exist then BULK INSERT Next file

I'm having an issue with BULK INSERT , the situation is the following : I've a folder path with probably 200 files in it but I've a table with 400 filenames tha

SQL executeUpdate() seems to commit data, but that is not the case. How can I find my error?

I curently work on few SQL queries (MSSQL 2O14), but only "SELECT" query works with executeQuery(). I had use execute() and executeUpdate() on "INSERT INTO" and

Get top n records for each group of grouped results

The following is the simplest possible example, though any solution should be able to scale to however many n top results are needed: Given a table like that b

problem with conditions in case when in SAS

I wanted to add a case when WPIS_ where if frm_code is one of the codes mentioned then we ASSIGNY W if not then B. I get "Syntax error" what I do wrong Rest cod

How can I Insert multiple rows with one query

I made a code allowing me to GET data from an API and insert it into a database. But I encounter a problem my api contains about 20 million data and to insert e

How to return multimap type with 3 tables (Android Room Databases)

I am trying to do a 3 way JOIN in my query for my Android Room Database. My tables relationships are: Table1 has a 1 to 1 relationship with Table2 Table2 has a

Update foreign key field in table to primary key values in another table

After adding SID to the TRANSACTIONS table, I need to update SID column in TRANSACTIONS based off STORE_NBR in the STORES table. Basically, I want to update the

I need to create a simple pie chart in SAS from a Proc SQL Table

I need to create a pie chart showing gender distribution for a state pulled through a macro variable. The code for the sql table looks like this: proc sql; crea

Trying to utilize a window function instead of this script

I'm trying to improve my query for this topic at hand. I'm trying to find the top 5 and bottom 5 growth rates per state from 2020 to 2021 in my org. The table h

What does a zero value coalesce function do?

I have been exploring dbt tools and I came across the following code snippet : coalesce(customer_orders.number_of_orders, 0) as number_of_orders I understand th

How to add a leading 0 in sql-server [duplicate]

I have to add a leading 0 in a column called houses, where it is a unique list of 3 digits, but I wanted have to add a leading 0 to it -->

How to create a SQL date range query where the date range depends on holidays and weekends?

I would like fetch all records in Postgres that match a particular date range. The column 'date' is of type Date. Return all rows where date is tomorrow's date

Get all rows from table and sort them by timestamp

I have these test tables which I would like to select and combine the result by timestamp: create table employees ( id bigint primary key,

Data Mismatch error while using the Update query

I am using the Update query inside VBA to Update one particular column. But I am getting the Data Mismatch in criteria expression error. Please find below the c

How to find a syntax error in my SQL code?

I am trying to compile my code but every time I get the same error: Syntax error (missing operator ) in query expression ' True Status.Subsystem Not LIKE '''

How to consecutively count everything greater than or equal to itself in SQL?

Let's say if I have a table that contains Equipment IDs of equipments for each Equipment Type and Equipment Age, how can I do a Count Distinct of Equipment IDs

Simple React/Heroku site not working when deployed, but works locally

When running this site locally, no problem. I have my server/client in different folders and the server is set to update the database on Heroku. I have one simp

Teradata SQL repeat insert statement

pretty new to teradata and trying to figure out how to repeat a simple insert statement. I have the following statement Insert into Test (Id) values ((sel max (

how to link two tables in the same database?

Trying to link two tables that are in one database please help with syntax