I have three SQL tables (A, B, and C), representing three different version of a dataset. I want to devise an SQL query whose effect is to extract the ids of rows/tuples whose values are different in all three tables. (Two records are different if there exists a field where the records do not share the same v…
Tag: sql
Failed to breakup Windowing invocations into Groups. At least 1 group must only depend on input columns
I have a dataset with booking hotels. date_in has format “yyyy-MM-dd”. I need select top 10 the most visited hotel by month. I get the following error: Error: Error while compiling statement: FAILED: SemanticException Failed to breakup Windowing invocations into Groups. At least 1 group must only …
MYSQL in AWS Athena
Using AWS Athena (so querying with MySql) I’m trying to retrieve information how many times the same IP has been logged. I have columns: timestamp, IP, country. I would like to count unique occurrences of each IP. I’m trying with this query but results are wrong: Thank you for helping achieving me…
update value only when value changed
I have to update main_table data from another table. Below is statement We will have value in any one column among value_string,value_date in a row or for a key, based on type_key. (like if type_key is string then value_string will have value and value_date is null). There is a trigger which ensure this const…
java.sql.SQLSyntaxErrorException: ORA-01797: this operator must be followed by ANY or ALL
My query is I get the error java.sql.SQLSyntaxErrorException: ORA-01797: this operator must be followed by ANY or ALL whenever i run it, What does it mean and how can I fix it ? Answer Your code is very messy and should be cleaned up. When asking the questions here you usually should create a MRE in which the…
How to give names to output tables?
I need to do a JOIN using two ouput-tables (these tables result from previous operations using other tables). I want to give them specific names to reference them. I’ve try ALIAS, AS, INTO, but nothing works. I am new in SQL and I’d really like some help here. My code is the following I’d li…
Compare the sums of 2 separate columns with an SQL Statement
I need help with the following code: Issue with the code: The resultant table contains only NULL in the delay fields. I’m unsure why this happens, as removing ArrivalsDelay and DeparturesDelay from the GROUP BY results in the SELECT failing, as I’ve not included ArrivalsDelay in the GROUP BY which…
How do you use mysql to only return a record if no conflicts exist?
Is there a way to have a SELECT statement only return a result if there exist no records in the database that conflict with the conditions? For example, people can reserve a table for two-hour blocks. A new reservation should only be allowed if there are no reservations that overlap with the new request. Some…
Invalid syntax error near ‘<' when using case when variable, works fine without variable
I am trying to resolve this SQL issue where my code throws an error Invalid syntax error near ‘<‘ when I use the variable @totalprice. Without using the variable, the CASE works and the query executes correctly but I want it as a variable Thanks Answer If you want to assign the result of the CA…
Extract strings till the second delim SQL
I wanted to extract all the details till the second /(forward slash)from my table in SQL Server. Any ideas? Answer Perhaps this will suit your needs: