I am trying to query a database table for a specific date range. When the dates are hardcoded, the query works without any problem, however, when I try to use the variables, Snowflake is returning an error message “”, there is no additional information. I have tried using Date, DateTime, DateTimeLTZ, Varchar datatypes but so far nothing has worked. Snowflake
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
Add a column and populate it with the queried values from another column
I have a column having dates in varchar format, I want to convert it, to date format, which I did through below query: Now, I want to create a new column and populate the column with the values that I got from above query. I am not able to do it with alter table. Any solutions? Answer Hope it works
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
Trying to write a query to specify if a customer has completed two types of a specific column
I have this table (resedtl) below… It contains information about a customer and the resType and the status of it. I am trying to determine if a customer has completed (status = done) both types of “RES” or only one or only two. I want to return something like this, where if custId is done for both resType 1 and
SQL Updating Values of Column for Each Unique Value in Separate Column (without a loop)
I’m currently writing a query that is grabbing data from a table and I want to update one of the columns in that table. The update needs to be based off the distinct values from one column. For example: Type ID x ID1 x ID1 y ID2 y ID2 z ID3 z ID3 The catch here is that I can’t
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
What is the right way to deal with the PreparedStatement in the Java program flow?
There are two methods in which the PreparedStatement is used. The first method is called in the second method. First method: Second method: The class in which both methods are located extends the JDBCBaseManager. JDBCBaseManager: The ResultSet in the second method still contains the results from the first method. I already tried to close the connection and open it again
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,
How to create flag 0/1 inform whether was changed or not during 4 months between two columns in PROC SQL in SAS Enterprise Guide?
I have table in SAS Enterprise Guide like below: name of table: table123 date typ: ID – numeric DT – numeric VAL1 – string VAL2 – string ID DT VAL1 VAL2 123 20210523 PR P 123 20211222 P P 222 20210502 PR M 222 20210711 M PR 38 20210513 PR PR 991 20211123 M P And I need to create