Category "sql"

MySQL normalization issue with performance

I have a table of shops and anoher table of shop configs (plan, discounts and Others configs), I need to add some Fields to store SMTP configs. Should I create

I have a SQL Table with employees and a timestamp for their every action. How to calculate how much they worked, and how much they idled (20min gaps)?

I have a very simple query that looks like this SELECT Username ,FORMAT(Timestamp, 'MM/dd/yyyy') as Date ,FORMAT(Timestamp, 'hh:mm tt') as Time FROM

Best way to check if database already exists with flask-sqlalchemy, otherwise create

I have a database app, and want to create the tables and database on the fly when starting the app for the first time. If the app is restarted, it should only c

Go_gorm: AutoMigrate with foreignKey( Failed to open the referenced table )

I've just entered stuyding Go language and try to use gorm connecting w MySQL. When I try to create tables with foreign key, it gives me same error "Error 1824:

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