I have a table called product_info where there are two columns(product, product_id).There are 5 ‘product_id’ and 10 ‘product’. I wrote the following code to list products and their count.Now I need to create an additional column called ‘favorite_product’ if the ‘produ…
Tag: sql
How do I select and count records less than 1 year old?
I’m using sqflite in my Flutter application. In this example, date is the actual date(10.06.2021) and DATUM is the datafield in the DB. I keep getting this syntax error: E/SQLiteLog(30657): (1) near “.2021”: syntax error in “SELECT COUNT (*) FROM Shisha_table WHERE (YEAR(10.06.2021) &#…
Customer/Material pair to count the occurences in the past 3 years and set the status flag. – aws redshift
I have a table with the following values date customer name material 9/1/2020 A A1 8/1/2019 A A2 8/1/2018 A A2 9/2/2020 B A1 9/2/2019 B A2 9/2/2017 B A2 So the output should be something like, if I could see a customer with a material, who has an entry in the past 3 years, then the status flag should
Oracle Apex – Case within a where statement
I’m having issues while running the following query (interactive report / simplified the query cause I’m sure the issue is with the case statement): The error is this one: ORA-20999. Does someone know why this is happening? (:p28 items are calculated via computations and work perfectly) Thanks! An…
How to query in sql with duplicate records?
Hi i have ITEAM A and ITEAM B table. For example Table 2) ITEAM B How to fetch records combined ITEAM A and ITEAM B with ascending order and duplicate records in sql? please help someone Answer
How to set an autoincrement composite primary key in oracle19c?
I want to create a table, with composite primary key and autoincrement, in Oracle 19c, like this: How I do it? Answer Create trigger on this table to achieve this result. Assume table name is test123
How to convert generic XML to a table row in PostgreSQL?
PostgresSQL v12.5 There is a table with single column containing strings formatted as XML. For simplicity let’s claim that there are no nesting: all tags inside <something> contain primitive values (strings). Assuming that there are much more elements than <a> and <b> inside, it would …
How to combine 4 sql queries into a single query with good performance?
I have a problem to solve. First I split this problem into parts and so I wrote four queries separately but now I need to put them together as if it were a single call to return a single result. How can I do this? 1) I select purchases according to branch and store 2) I validate if the promotional
Is there a way to show only the top 2/nth of a query after “group by” country? – bigquery SQL
I am doing a query on Google Big query, I have joined the 2 tables and created a new column “total gmv” using “SUM” to represent the total revenue, now I wanted to show only the top 2 vendors , GROUP BY country in my query. I manage to show total_gmv group by COUNTRY and vendor_name, b…
SQL syntax to achieve the “opposite” of LIKE
I’m very rusty on the little SQL I once learned, and while I totally get SELECT column1 FROM table WHERE column2 LIKE pattern, what I need is: For example, I might have a product family table which has information about the Coca Cola range, and for which I might store coca% in column2 ready to match spe…