Category "sql"

how to calculate YTD (Year To Date) value in Oracle table

There is a table and its data looks like this: year month v1 v2 2017 1 2 3 2017 2 4 5 ... .. .. .. 2017 12 9 3 2018 1 1 3 2018

how to fix ORA-06575: Package or function is in an invalid state error

I'm looking to create a package, already have a working procedure. Working on a function, step by step and I have encountered an ORA-06575: Package or function

How to make case in HANA

I have the following query in postgres which gives the meter range and the number of vehicles travelled between the range SELECT (CASE WHEN meter >= 0 AND m

SQL (INSERT INTO) COMMAND DOES NOT WORK IN OLEDB IN VB.NET

I want to update in the "CIU" column in the database "GSDTS" and retrieve the data or values from the database "IFGTS" in the column "PRSOBNET" based on the con

Acces to MySQL automatic data transfer

I have to pass data from Access database to a MySQL database attached to HeidiSQL automatically every minutes. To do that i put the data into excel files format

Alternative for Cartesian and Cross Join

I want to output all the possible combination in two tables without using cartesian join or cross join. Is this possible?

Maximum number that can be returned by 2 Natural Joins

Given relations A(a,b,c), B(e,f), C(d,g,h), where A has 800 tuples, B 200 and c 500. In worst case gives the expression A * B * C ( with * natural join) : a) 8

trigger in PL/SQL

There are two tables given: 1) employee(eno,ename,basic,da,gross) da=basic*(5.0/100) gross = basic+da 2) sal_hist(eno, sys_dt, old_basic) How to write a

MySQL v8.0.13 Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release

Executing the following query in MySQL v8.0.13 results in this error: 0 row(s) affected, 1 warning(s): 1287 Setting user variables within expressions is deprec

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