We have the fixed format data and it has the number with plus/minus sign, like +00005 or -00005. We’d like to convert it to number but Redshift seems not to allow implicit conversion. So, I temporarily use to_number(replace(<numbercolumn>, ‘+’, ”),’99999′) But I guess…
SQL query to delete records when the difference between two dates is greater than a certain value
I would like to delete records when the difference between SYSDATE and a TIMESTAMP (6) field of my table is greater than 10 days. I have created the following query: but i get the following error: am i creating the query correctly? Answer am i creating the query correctly? No, you cannot refer to an alias in …
SQL get total sellers of product category
I have like this database tables: Table categories Table products Table product_varieties I have query to get price min, max and avg in each category: Now I need get total users (sellers) of each category by editing my current query. I tried like this: But my query not work and return error with message: How …
Trigger Not Running Check Whether it is correct or not? [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 last year. Improve this question This is my trigger and its running perfectly with the help of stackoverflow.com I edit my ques…
How to select data where more than one column is populated
I have a sample table, called [SAMPLES] which I’ve added multiple columns to the end for different types of lab analysis results, however for the majority of samples only one analysis has been completed. I want to be able select only the samples where more than one analysis has been completed on the sam…
Postgres stored procedure(function) confusion
I’m pretty new to Postgres and SQL as a whole and could use a bit of help with a function here. I have this table: What i need is for a function to take as input plate, start date and end date and throw an error if the table contains any row with the same plate where the rental period
Method returns a value but the property does not hold it
The method LocalizaArquivo() calls the method VerificaArquivoCarregado() that checks if the file is already loaded. If it is loaded returns arquivoCarregado = true. When I debug it, I can see that arquivoCarregado = true, but after the method VerificaArquivoCarregado() is finished it changes to false. The pro…
How do I use a prior query’s result when subtracting an interval in Postgres?
I have the following code: How do I use example_var in in the interval? I’d like to do something like – interval CONCAT(example_var, ‘day’) so that I could change what example_var is equal to and therefore change the length of interval but that isn’t working. Answer If you want t…
MySQL Merge two queries based on mutual column
I have two queries that retrieve records from 2 different tables that are almost alike and I need to merge them together. Both have created_date which is of type datetime and I’m casting this column to date because I want to group and order them by date only, I don’t need the time. First query: Se…
Oracle display number of unique values for column combination
I have the below table C1 C2 C3 A1 A2 A3 B1 B2 B3 C1 C2 C3 C1 C4 C3 For each unique combination of C1 and C3, I would like to keep the first value in C2, but storing the count of unique elements …