Skip to content

Tag: sql

Ambiguous Source ID

I’m not sure what I’m doing wrong here. I tried to make an alias because it exits as an item in both tables I’m trying to join, but I keep getting an ambiguous error for sourceId. Answer try this change the alias for select depending on which table it is in Also are you purposely joining on …

Constraint on size of array type in Postgres

I have the following schema for a table (simplified for the sake of discussion) : A task transitions from NOT_SOLVED TO SOLVED when array_length(current_solved_by) == max_solved_by Questions: Is it a good practice to maintain another column, in this case state, which can be derived from other data (Based on s…

Divide the results of two select queries

I have two SQL count queries that on their own work fine, they are: Now how to do I add to the query to get the percentage of 26/130?? I have a new query to go along with how to get percentages. Here it is: this brings back results below: If I remove the Distinct from my query there are

Extract year from timestamp in hive

I am writing the query to show the data entries for a specific year. Date is stored in dd/mm/yyyy hh:mm:ss.(Date TIMESTAMP – e.g. 12/2/2014 0:00:00). I am trying to display the two columns(name, orderdate) filtered by a specific year(year from orderdate). The requirement is to enter the specific year(20…