We have two tables in BigQuery like below: Table A Name | Question | Answer —–+———–+——- Bob | Interest | a Bob | Interest | b Sue | Interest | a Sue | Interest | c Joe | …
Why am I violating an integrity constraint? (ORA-02291)
When I try to alter one of my tables to set one of it’s rows as a foreign key, I get the following error: “ORA-02291: integrity constraint (SYSTEM.M_FRAN_FK) violated – parent key not found” This error only occurs when I insert a row into the database with a none-null value. I’m …
I want to join two tables, removing duplicate values
I have to say I’m an amateur on MySQL, plus english is not my mother’s language. Here is my first table “Teacher”: And here my second table “Course”: I would like to know which country has more teachers giving courses, but I don’t want that it count the same teacher t…
Order by descending aggregation within window function in PostgreSQL
I have a dataset that features duplicate values of the the primary variable, something like the following: I have achived this by using the following code However, my desired output needs to be ordered such that counts is descending yet col1 remains partitioned, so that I can see, for example, which value fro…
i need a query to update column transferred_to to ‘Invalid_destination’ in Storage table if transferred_to column is equal 100
the query that i tried is this But i got this output so this is my table Answer You seem to want: Note that storage is a language keyword in MySQL, hence a poor choice for a column name. It would be simpler to use another column name, otherwise you need to quote it.
IDENTITY is red underlined while trying to create a table in SQL
I’m a Java student and I was trying to create a table for my database web app project. So I used IDENTITY(1,1) to get the id start from 1 and auto increment by 1. But IDENTITY is underlined and I do not know why. Also when I try to run the code I get this Output : Answer You have
Better way to find records meeting two different aggregate criteria?
I need to find customers that have a sum of credit transactions greater than or equal to a threshold amount and a sum of debit transactions less than or equal to the inverse of that same threshold amount. I also want to return the transactions whose aggregate transaction amount satisfies the credit and debit …
Date distinct count over week
Im trying to get a distinct count of user ids logs per day with every week as a partition for the distinct identification. e.g. if one user logs on Friday/Saturday of week 1, and on Monday/Friday of …
How to assign a field name to an SQL Count in AWS Athena SQL
I’m still new to Athena. I think I got my database defined correctly, as shown in Example 1 below. However, when I run a count query, I get results unlike what I would expect. Example 1: Works Fine except count is called “_col3” Result: Example 2: syntax error This query shows a syntax error…
Define Position based on lowest ID and Foreign Key in MySQL
I am currently facing the following issue: I have 1 Table with my Broker Trading Data similar to this: The Goal is to say IF first OrderType (lowest Id where TradeId is the same) was a Buy, it’s a LONG Trade ELSE a Short Trade … output should be like this: What am I missing? How can I construct my