I have a little issue with my SQLite query which I use in python. In my little test_table I got 4 columns: sys_id, aq, vq, off_id. If I search for example for off_id=7477310 I get results: But I would also like a direct comparsion by this priority (vq,aq,sys_id) so I tought I use max. So the goal is if one
Tag: sql-order-by
Postgres order entries by id, self reference id and date, after every parent, list childs
I have the table orders with the following fields id, updated_at, self_ref_id, and others which doesn’t count. The column self_ref_id is a self reference two an order, one order can have multiple children, a child will not have other children. I am trying to order all entries by updated_at desc but after every parent order, I want to have his
Sort by NULL field only if field is NULL, then sort by name in Postgresql
I have the following sort in Postgresql: What I want is having all records with verified_at NULLS first, but only if the field verified_at is not null, then order by name. I don’t want the verified_at to have the priority on name if verified_at IS NOT NULL. With this code, verified_at has the priority on name, after the NULLs are
How can I get the 10 most recent rows from a database?
I want to choose an id in a table, sort it by date and show only the 10 newest entries. I have already tried following command: SELECT * FROM weather WHERE DATUM = (SELECT MAX(DATUM) WHERE ID=’0′)
Selecting 7th Person (row) and get 7 as result
I want to select the 7th person (Pierre Gasly (for example)) Score list Season F1, so I can return number 7 in my C# application. SELECT CONCAT(strVoorNaam, strTussenVoegsel, ‘ ‘, strAchterNaam) AS …
Sort a table but keep groups of rows together
How do I sort a table by it’s minimum value per group but at the same time keep a group of rows together. Below a simple example of what i am trying to accomplish. The table is sorted by the lowest group value, but the group remains together. I am pretty sure this question has been asked already but i
how get random questions from database include Categories?
Hallo i try to make a simple quiz application in php based on math tests from many years. I have database with such columns: -id -pytanie -a -b -c -d -poprawna -rok_id -typ_id I use rand function to get random id and next i use this in sql answer to get random question. However id dont know how get radnom
SQL order with equal group size
I have a table with columns month, name and transaction_id. I would like to count the number of transactions per month and name. However, for each month I want to have the top N names with the highest …
How do I sum up each Month of data for each product?
I have a set of data such as: Date Product Volume 01-01-2020 A 5 02-01-2020 A 25 03-01-2020 B 20 02-01-2020 B 10 04-01-2020 C 5 02-02-2020 …
MySQL ORDER BY two clauses (descending and ascending)
I have this table: create table products(name text, quantity int); insert into products values (“A”, 10); insert into products values (“B”, 0); insert into products values (“C”, 15); insert into …