For a minimal, reproducible example (reprex) let’s assume I have a database object (dbo) in a Microsoft SQL Server and I want to query things in T-SQL. My dbo looks like this: Animal-ID Marker-ID …
Sum some columns order by ID in SQL [closed]
I’m trying to sum some columns by id. But I’m retrieving 1 raw. For Example Id | C1| C2| ——————————— 1 | 2 | 1 | 2 | 5 | 4 | 3 | 3 | 1 | 4 |…
Error in SQLite ‘all VALUES must have the same number of terms’
Glad to be a part of this platform among you, highly experienced programmers, Nowadays I am working on a POS system project in python, using tkinter for frontend & Sqlite as the database. While putting data into it, I am facing this issue. ”’ ”’ What I am trying to do here is retri…
Need to modify a variable data to use as a “LIKE” in a COUNT query
I’m trying to use a numeric variable on a LIKE statement, but I do not know how to change the data to a numeric value. Before we start, I apologize because I can’t copy the table structure as I’m …
Oracle SQL where clause does not work for some dates
Below query works fine with the recent dates (for e.g. if the date is 20-JUN-16, 30-SEP-19). But if I query with date value set to 29-MAR-80, 01-JAN-94 it does not return any result. Wondering what could be the reason. Am not allowed to change the existing year format to YYYY. We are on Oracle 19c. Answer Her…
Find items in table with 2 specific sizes
I have items table where the item code repeats as it has different sizes, variants. I want to find items which has 2 specific sizes, ie size in both M/Y and Euro. Items table: Required, I want to query for item id 1 and 3. I was trying with SUM(), CASE but not able to figure it as it involves
Three-Way Diff in SQL
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…
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…