I wasn’t sure how to title this question, but I’ve got an Oracle table that has a column for each day of the week. These represent the days a business is open. The values in these columns is either ‘Y’ or ‘N’. This is how the table was setup years ago and I am unable to cha…
Tag: sql
How to get all the dates between the date range (inclusive start_date and end_date) [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question How to get all the dates between start_date and end_date, including start_d…
Set character set in sqlite [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question how to do character set in sqlite query.enter image description here Answer You have to use t…
MySQL query for multi-column distinct plus an ancillary column condition
Imagine a flat table that tracks game matches in which each game has three participants: an attacker, a defender and a bettor who is wagering on the outcome of the battle between players 1 and 2. The table includes the names of the players and the bettor of each game, as well as the date of the game, the scor…
HIVE converting unix timestamp for calculation
I’m trying to perform subtraction among timestamps and would like to convert the timestamps in forms that can be converted to minutes. I used regexp_replace to convert timestamp in such form: The following code will convert it to seconds I have other two timestamps that I wish to convert to seconds, suc…
How to make it into BCNF
Good morning, I wonder how I can make sure this schema is in BCNF. petition(ID, title, contents, budget, organizationID, official, resultID, applicantID) applicant(ID, name) official(ID, name, department) organization(ID, name, phoneNumber) *Each petition has an official. *Each petition should have more than …
postgresql subtract between row while column shift
I have a simple table like this I would like to subtract row of yesterday on day(i+1) to row of today on day(i). For example, if today is 2020-01-02 the expected results should be the 0 (day0) was obtained by 2 (from 2020-01-01 day1) – 2 (from 2020-01-02 day0) the -2 (day1) was obtained by 1 (from 2020-…
Transform Columns to Rows dynamically using T-SQL
I have the following table where I need to transform Columns to Rows tbl_Survey: I need to have the following result: To have this result I used the following code: But, my Quest_1, Quest_2, Quest_3 values could potentially be changed / or even added a new once… Are there ways to code them, so it can be…
Right syntax to use near ORDER BY when I try to delete some number of rows
When I try to delete some rows from tables (rows got from joined tables) (Ex : if I get 10 records, then need to delete first 2 records) using ORDER BY ASC and LIMIT = 2. But getting error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right
Left Join – attempting to identify instances where child records do not exist, or if they do exist, populate unique records meeting specific criteria
I am attempting to search an SQL database for instances where child records do not exist, or if they do exist, they are a specific type (e.g. Historical) and no other types exist (e.g. Current): This populates all of my parent records that do not have any child records without any issues. However, I also want…