Multicolumn order by a tuple – Postgresql
Lets supose I have a tabla A like: bisac1 bisac2 bisac3 desire x y z 10 y z x 8 z y x 6 x y p 20 r y z 13 x s z 1 a y l 12…
Lets supose I have a tabla A like: bisac1 bisac2 bisac3 desire x y z 10 y z x 8 z y x 6 x y p 20 r y z 13 x s z 1 a y l 12…
I have the following table: product price date banana 90 2022-01-01 banana 90 2022-01-02 banana 90 2022-01-03 banana 95 2022-01-04 banana 90 2022-01-05 banana 90 2022-01-06 I need to add a non-unique ID column to the table. Every time the…
I would like to delete rows from my database that have the same name. I've checked Stackoverflow and found something like this: DELETE FROM my_table mt1 USING my_table mt2 WHERE mt1.my_name = mt2.my_name AND mt1.unique_id<mt2.unique_id; This of course works but…
I have two tables I need to join these table and there is a possibility that joined table might return duplicate rows but there is column updated date which will be unique so I need to fetch record from these…
Print all details of the 16th order placed by each customer if any. How to print exact 16th Order? SELECT COUNT(orderId) FROM orders GROUP BY CustomerID ORDER BY CustomerID;
I have a table similar to below (PatientData) | id_number | phone | email | dob | | -- | ---------- | ---- | ---- | | 6 | 04-------61 | [email protected]| 196949200 | | 5 | 04-------61 | [email protected]|…
I can get the rank alias with this query: SELECT *, RANK() OVER (PARTITION BY some_field ORDER BY value) AS rk FROM my_table Result: some_field value rk same 10 1 same 20 2 same 30 3 And I tried to…
I'm fairly new to window functions and have been learning about them recently. There is this query which returns the total sales for each month and quarter using a group by and an aggregate function. Additionally, it returns the total…
I have a table similar to this: product_id client_id category price created_date 1 1 A 3.1 2022-11-01 2 1 A 3.2 2022-11-02 3 1 B 3.3 2022-11-03 4 1 B 3.4 2022-11-04 5 2 B 3.5 2022-11-05 6 2 B…
I need to write SQL query to output the Maximum number and Minimum number of movies produces by diffrent actors and actresses between year 1991 and 2001 query written . When I tried this, I got error enter image description…