Skip to content
Advertisement

Tag: sql

Condition to SUM previous values – SQLite

My following SQLite database: Explaining brazilian tax income: a) if I have loss, I don’t need to pay any tax (e.g.: January) b) negative results can be subtracted from the next month positive outcome (e.g.: in February, instead of paying the full tax for $ 5942, the tax can be applied only to (5942 – 3200) = 2742. c) if

Converting decimal to Date

I have a column with dates formatted as decimals, for example: 20,210,830. I want to convert this number to date format as 08/30/2021 I have tried to use convert and the database shoots me an error that convert is not a valid function. Cast seems to work but, only returns a null value every time. This statement will validate: This

Oracle SQL – Create Sequence and add sequence values on new column

I have the following table called table_1 I create a new column_3 then I create a sequence CREATE SEQUENCE “sequence_1” MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOPARTITION and I alter the table_1 so the default for new values on column_3 are the the values of the sequence. ALTER TABLE table_1 MODIFY column_3

Get List of Users for a Specific Local Time

In my database, I have a list of users with the user ids and their UTC offset in minutes. It’s in a PostgreSQL database which I access through sequelize in my node application. For example: I want to create a query that, when run, gets me a list of users that have passed 12pm noon their local time. For example,

Advertisement