Category "sql"

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

Get Hieararchical data as JSON from SQL Server

I have following table: Id HieararchyId Name 1 / MHz 2 /1/ Finance 3 /1/ IT 4 /1/3/ Software Development 5 /1/3/ QA 6 /1/2/ Accountant and I want to get data

Select MAX value and GROUP BY

I'm trying to extract ID values where End_Time for type A is not equal to Max End_Time of each System_Id ID System_Id Type End_Time 1 1 A

Get Hieararchical data as JSON from SQL Server

I have following table: Id HieararchyId Name 1 / MHz 2 /1/ Finance 3 /1/ IT 4 /1/3/ Software Development 5 /1/3/ QA 6 /1/2/ Accountant and I want to get data

Adventureworks exercises SQL Server

Using the SalesOrderHeader and SalesTerritory tables, write a query to calculate the number of transactions and total monthly amount per territory for each of

Snowflake CONCAT strings with DISTINCT values

I am doing a merge where a string exists in my target table. To this I want to concat a new delta value which is a ; separated string list in my WHEN MATCHED ..

deleting specific duplicate and original entries in a table based on date

i have a table called "main" which has 4 columns, ID, name, DateID and Sign. i want to create a query that will delete entries in this table if there is the sa

Migrating T-SQL script to Snowflake - error invalid identifier

I am currently trying to migrate a T-SQL script to Snowflake. This is the T-SQL script: SELECT * —- a bunch of stuff FROM TABLE_DATE D LEFT JOIN

SQL Find Most Frequent Route

Departure Destination FlightCount A B 5 B A 4 A C 7 C A 1 I need to find the most frequent flight regardless of the flight directions from the above table. Fo

Make nested SQL queries

I want to do a Nested query to add the same data but with different filters. I have tried something like this but that gives nothing or doesn't execute: Select