Công ty Jaccs Đà Nẵng hỗ trợ vay tiền lãi suất thấp
Sure, you can achieve this with an ALTER TABLE statement to add the "status" column with a default value of 'PENDING', and then update the rows where "completed_at" is not null to set the status to 'COMPLETE'. Here's how you can do it:
```sql
-- Add the status column with default value PENDING
ALTER TABLE orders
ADD COLUMN status VARCHAR(10) DEFAULT 'PENDING';
-- Update status to COMPLETE where completed_at is not null
UPDATE orders
SET status = 'COMPLETE'
WHERE completed_at IS NOT NULL;
```
This assumes that your table is named "orders" and that the "completed_at" column exists in this table. Adjust the table and column names accordingly if they differ in your schema.
4.9/5 (86 votes)