Category "sql"

way to check if two intervals overlap in amazon Athena / Presto

I am wondering if we have a way to check if two dates overlap in amazon athena (when writing an athena query) . I can do this in R / Python using the int_overla

Return smalldatetime value from scalar function SELECT query

I'm looking to create a scalar function in SQL Server (2017) that leverages a calendar table I built awhile back in order to calculate and return a date a given

Remove banned words then collapse the data

Gets 'exact' banned words matched against a set of blog comments. It then creates a result set collapsing the banned words into the owner (the blog comment) sho

Pivot data based on category and date field

I have to identify the records with check_in category of S1, T1 and P1 in the check-in-order and pivot the rest of the data until we hit the next category. I wa

Is there a way to completely reset a SQL Server instance without uninstalling?

This is using Microsoft SQL Server 2012. I have a program that has multiple versions, each one has some schema changes to the underlying SQL database. In an at

How to break datetime in 12 hour chunks and use it for aggregation in Presto SQL?

I have been trying to break the datetime in 12 hour chunk in Presto SQL but was unsuccessful. Raw data table: datetime Login 2022-05-08 07:10:00.000 1234 2022

compare two tables having same column name but different date column names

I have table A id1 dt x1 2022-04-10 a2 2022-04-10 a1 2022-04-10 x1 2022-05-10 x2 2022-04-10 y2 2022-04-10 y1 2022-05-10 x1 2022-06 -10 Table B id1 dt a1 2022

Snowflake subquery

I have two tables. Transaction(ID, TERMINALID) and Terminal(ID, TERMINALID, EXPORT_DATE). The goal is to obtain for each row from Transaction table newest recor

dataframe dtypes to create table sql stat

I need to insert into a CREATE TABLE stat the names of the columns and the types, with the comma at the end of each line. What I get with df.dtypes is: Name

Writing a query for alternative column names as mentioned below eg

The query for, If the address is missing, displays the email id. If both address and email are missing then display ‘NA’. Give an alias name as CONT

How to get only those objects whose subarrays in the arrays match the requested one with SQL and Hibernate?

I have Project objects that contain arrays of Tags (for example, Backend, Frontend, Sales, Marketing). The user sets the desired parameters, such as Backend and

Best practices on primary key, auto-increment, and UUID in RDBMs and SQL databases

We're designing a table for user entity. The only non-trivial requirement is that there should be a permanent URL to the user entity (for example their profile)

Getting the median value from the database

A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION an

How to improve an Update query in Oracle

I'm trying to update two columns in an archaic Oracle database, but the query simply doesn't finish and nothing is updated. Any ideas to improve the query or so

Mysql set default value to a json type column

I heard that mysql version prior to 8.0.13 accept default value for json type column, so I using the cmd: ALTER TABLE templates CHANGE COLUMN values JSON NOT N

Why role cannot be dropped because some objects depend on it

Database "mydb" is owned by role "mydb_owner". User "currentuser" tries to delete role "roletodelete" from this database using revoke all on all tables in

Convert select query results into Json

I want to execute a select query on a table and I need this result in a JSON format or in an excel sheet. I want to do this using query only and I'm using SQL S

PL SQL String Manipulation (Deconcatenate based on multiple delimiters)

I have string such as A~B~C,D~E,F~G~H,I. The string is comma separated and then each comma separated substring is ~ separated. There is no limit on the number o

Error: NoSuchMethodError: The getter 'sessionToken' was called on null

Hello fellow programmers! I am starting in the world of Flutter programming. I am following a course on Udemy, the questions are never answered by the teacher a

sql two table select data with desc limit 5 ( or select data in two table last 5 entry)

<table id='simple_table' > <tr> <th>customers ---</th> <th>visitors ---</th> <th>not show only for com