Consider table
CREATE TABLE `contact` (
`id` INTEGER,
`name` TEXT,
`category` INTEGER,
`freed` INTEGER DEFAULT 0,
PRIMARY KEY(id)
);
I want to make such a query or view, that will duplicate rows with freed = 1 AND caregory IS NOT NULL, for those rows category should be set to -1. Rows with (category is null and freed = 1) should be removed.
First picture shows data source. Second picture show desired result.
3 new rows should be added ( Jin,-1,1|Tih,-1,1|Traph,-1,1)
1 raw was souldbe remove (Traph, null, 1)
WHERE NOT(category is null and freed = 1)
ORDER BY category IS NULL ASC, category = -1 ASC, category ASC , name ASC
Aucun commentaire:
Enregistrer un commentaire