Category "sql"

How to test a repository with a user that have update rights and the test needs tot add records to the database

I use mysql and spring 5, spring-data-jpa and spring-boot and JUnit5. This must be a common problem but I don't see te sollution. I have to test a repository wi

Vertica SQL: Disregard rows, based on two conditions

I need a where condition that considers to following for an entire table: If a 0 exists for an ID (in column d) then exclude everything that is >0, if 0 does

Best Method to Delete 12M rows from SQL table

I have a table currently with 100M+ rows of telemetry data. The table often receives duplicate records. I can identify duplicate records using a row_number() pa

AWS Athena/Presto SQL: Having trouble getting null values

I am doing a query in aws Athena where I want to get some total values, however I am having issues getting a column where the values are null, this column somet

How to get the last day of the month without LAST_DAY() or EOMONTH()?

I have a table t with: DATE LOCATION PRODUCT_ID AMOUNT 2021-10-29 1 123 10 2021-10-30 1 123 9 2021-10-31 1 123 8 2021-10-29 1 456 100 2021-10-30 1 456 90 2021-

How to share datafram from multiprocess to main process?

Here's the 2nd version coding I'm using now( it's from Booboo), it takes about 17mins to return query result, and data could be transfer to patrent process. fro

How can I concatenate all values in descending order that have the same primary key in HIVE?

I am using HIVE and I have a table like this: S.no ID applicant_num f_name l_name Primary Key 1 123 202201A1 akhil yadav 123~&~akhil~&~yadav 2 123 2022

How to get all the objects in a table where the coordinates intersects with polygon with SQL Spatial Data

I have an SQL table which called DATAB which contains thousands of objects ordered by the following colunms: [id] [angel] [latitude] [longitude] And i have this

Getting previous month of last year

I want to get the previous month data but of the following year. So if it's May 2022, I want the data for April 2021. Here is what I currently have, but it is s

Snowflake's `try_to_geography` raises an error instead of returning null

I am trying to run a query in Snowflake to convert a GeoJSON object into Snowflake's baked-in geospatial data types: SELECT id, -- some other columns TRY

Getting previous month of last year

I want to get the previous month data but of the following year. So if it's May 2022, I want the data for April 2021. Here is what I currently have, but it is s

Snowflake's `try_to_geography` raises an error instead of returning null

I am trying to run a query in Snowflake to convert a GeoJSON object into Snowflake's baked-in geospatial data types: SELECT id, -- some other columns TRY

Stored Procedure Snowflake - time formatting issue

var get_end_time = "select CURRENT_TIME()"; var time_sql = {sqlText: get_end_time}; var time_create = snowflake.createStatement(time_sql); var time_exec_end = t

Selecting rows with id's from two other tables

Let's call this table service_status: +---------+----------+-------------+------------+ |service_id| output | created_at | updated_at | +---------+--------

Full text search failure on PostgreSQL

I have a PostgreSQL used to index text content. The SearchVector column is created successfully using the following code UPDATE public."DocumentFiles" SET "Sear

Is there a free version of SQL server that has Integration Services Catalog too?

Trying to understand what free version of sql server allows to create Integration Services Catalog for SSIS pacakges. Any help is appreciated. Thanks.

How can I count a value in SQL

I have a table with the columns company_id, shipment_id and trip_id. I am asked to find out which companies have less than 4 shipments on a single trip. The que

Teradata - YEARFRAC equivalence

I am having a hard time trying to find something that would be equivalent to YEARFRAC (Excel) for Teradata. I messed around with the below, but want I want it t

how to create a user in postgres to connect to nodejs?

It is my first time using postgres and I am trying to use it with node. I installed postgres in Ubuntu and created the user admin sudo -i -u postgres createuser

Avoid incrementing primary key if insert is not successful?

I have a 'locations' table as follows: Using an API, if I send a valid record, the table will start normally with index 1. If I send something that won't be ac