Im reading data from a tsv-file to a postgresql table. The problem I have is that in one column (death year) it is either a year or N if the actor is not dead yet. If i try to use INTEGER as data type I get an error because of the N. Do anyone know how to solve this? This
First load table in CTE and then query the CTE?
A colleague of mine writes views like this: He says that his professor taught him this because ‘things will be loaded in RAM and it is a lot faster’. Unfortunately the professor is no longer able to explain this. I think the following works at least as good and avoids unnecessary complexity in the code. Am I missing something? I
SQL server: Question about query group and auto id
i have a table which has 2 columns like this, picture is input and output: Explain input: 2 column is 2 person who relation ship together. Exam: A relation with B, C,D,H Output: i want to merge 2 column , with Column group ID auto and column RelationShip ID group auto: i tried query: row_number() OVER (ORDER BY [columnA]) n
Convert date into sfdate for snowflake
I’m having problems working with dates in Snowflake using Snowflake’s Javascript. One select queries and gets a date. It’s declared in the source table as a date. I want to be able to add 1 day to …
Combine ORDER BY and GROUP BY and a counter
I use this SQL query to get customer order lines from an imported CSV file and get this result Now I would like to produce 2 different results, where one, in addition to order by ordernr also group them by their customerid and another where I get a counter (the cnt column) with how many times a customer/customerid occurs I’ve
How can I avoid duplicates accross multiple columns in access?
My question is pretty simple, yet I am unable to find the answer I need. I have an access database with a table called coaches. I have another table called teams, which can have a coach and assistant coach. I need to be able to allow no duplicates across the “Coach” and “Assistant Coach” Fields. Coaches can be both head
MySQL: Why using where on date column does not use index
I have a table which has a column with type Date which is shown like 2020-06-30 I want to find rows where year of the date column is 2020 in them. The problem is even though its indexed, when I run this: explain select * from table where YEAR(date_c) = 2020; the key and possible_keys are both null. what should
Creating a PIVOT with dynamic rows and columns – SQL Server 2016
First, let’s define the tables: The following query gets all the answers with questions for a specific reviewee: And the output looks more or less like this: What I want is output that looks like this: The number of questions and reviews/review_dates is not known until runtime. I am ultimately writing this query for a VB/ASP front end, so if
Divide Zero error when calculating Sales % in SQL
I keep getting the following error message: Msg 8134, Level 16, State 1, Line 1 Divide by zero error encountered. I’ve seen some posts about using IFNULL which I have tried. For example: But this returns the following error: ‘IFNULL’ is not a recognized built-in function name. What I’m doing is trying to calculate the proper sales percent and then
Subtract a number from the rows until the number ends to zero
How can subtract a number from the rows to the end of the subtraction in MySQL with query update If have table like this and i want subtract “80” form qoh to get the output I tried by and not work What is the appropriate adjustment to do? Answer If you are running MySQL 8.0, you can do the computation