I have this table as an example:
CREATE TABLE "public"."items" (
"name" text NOT NULL,
"type" text NOT NULL
)
With initial values:
INSERT INTO "items" ("name", "type") VALUES
('apple', 'fruit'),
('banana', 'fruit'),
('chair', 'furniture'),
('table', 'furniture'),
('grape', 'fruit'),
('cabbage', 'vegetable'),
('beef', 'meat'),
('water', 'drinks'),
('lamp', 'furniture');
How can I query rows from this table with one statement so that I get the rows with the fruit type first?
Given that:
- There's a lot of
types (could be in thousands of differenttypes) - I don't care the order of the result other than I want to prioritize getting
fruittype first
For example if I want to query 5 rows from this table, the result would be 'apple', 'banana', 'grape', 'cabbage' and 'beef'.