I have a table of transactions where a each transaction has a transaction_id, an item (what item was purchased in the transaction) and a customer_id (person who ordered the item). How can I pull all transactions only for items that have been purchased by both customer_id 100 and customer_id 101 at least once?…
Update in DB2 using where exists instead of join
I’m trying to perform an update in DB2, which I started out trying with an inner join, but DB2 won’t allow that. I altered it to use a ‘where exists’ clause but now it’s telling me that main_discount in my set clause is not found (I’m assuming because it isn’t referen…
Trying to exclude certain users
New to SQL but I’m trying to find titles wherein the words “blue” and “black” are present. However, they cannot be from users who have ids of 1 and 5. This is what I did: However, when I add that id 1 and id 5 shouldn’t be in the query, it shows me something like this: Blog…
Hasura GraphQL query : where clause with value from related entity
I recently started using GraphQL through a Hasura layer on top of a PostgreSQL DB. I am having troubles implementing a basic query. Here are my entities : article : articleId content publishedDate categoryId category : categoryId name createdDate What I am trying to achieve, in English, is the following : get…
Oracle partitioning by range
I need to split the table into partitions, namely into three partitions according to the EVENT_TIME field, where the first partition is an interval of a week from today, the second last week and the third partition is history, where data that does not pass into the first two partitions are placed. In addition…
Count distinct customers who bought in previous period and not in next period Bigquery
I have a dataset in bigquery which contains order_date: DATE and customer_id. I try to count distinct customer_id between the months of the previous year and the same months of the current year. For example, from 2019-01-01 to 2020-01-01, then from 2019-02-01 to 2020-02-01, and then who not bought in the same…
How to analyze metadata of given schema name and table name dynamically in Oracle?
I am trying to write a dynamic oracle plsql script that takes schema_name and table_name for parameter and returns Primaty Key Column names,Index flag(if table contains index returns 1 else 0),data volume for size of table in db,row count and column count of selected schema and table.Here is my code It gives …
How to add ” and , for multiple ID in SQL Server
I am writing a SELECT query that has multiple id, and I have to manually add ”,” (e.g ’12L’,’22C’). I have around 2000 id in an Excel sheet. Is there any quicker way to add ”,” to all the ID? Answer Here is a conceptual example for you. It will work in SQL Serve…
Select data based on certain set frequency
I have the following table settings What I need is to select the entry based on whether it is allowed to trigger on date that or not. So lets say for example for the following entry id:xxx, trigger_metric: MONTHS, trigger_frequency:1 , trigger_start_date:’2021-09-01′ the row should be selected on …
Unable to differentiate between words consisting of different Unicode letters in mysql and phpMyAdmin
I am inserting a word using the following sql query from a php script. $sql = “INSERT IGNORE into cb_words (word, user_id) VALUES(‘$word’, $user_id)”; The problem arises in this particular …