Copy what you need, then edit field/table names to match your data. Remember to double‑quote identifiers like Salesforce fields (e.g., "Site_Contact__c").
Create a table from a selection
CREATE TABLE "Hot_Accounts" AS
SELECT *
FROM "Account__export"
WHERE "AnnualRevenue" >= 1000000; -- adjust threshold
Update columns based on criteria
UPDATE "Account__export"
SET "Rating" = CASE
WHEN "AnnualRevenue" >= 1000000 THEN 'Hot'
WHEN "AnnualRevenue" >= 250000 THEN 'Warm'
ELSE "Rating"
END;
-- Update from a correlated subquery (emulates UPDATE ... JOIN)
UPDATE "Quick_Quote__c_export" AS q
SET "Site_Contact__c" = (
SELECT a."Primary_Contact__c"
FROM "Account__export" a
WHERE a."Id" = q."Account__c"
)
WHERE EXISTS (
SELECT 1 FROM "Account__export" a WHERE a."Id" = q."Account__c"
);
Create new columns
ALTER TABLE "Account__export" ADD COLUMN "Segment" TEXT; -- SQLite supports ADD COLUMN
UPDATE "Account__export"
SET "Segment" = CASE
WHEN "AnnualRevenue" >= 1000000 THEN 'Enterprise'
WHEN "AnnualRevenue" >= 250000 THEN 'Mid‑Market'
ELSE 'SMB'
END;
Insert rows
-- Insert literal values
INSERT INTO "Account__export" ("Id","Name","Site_Contact__c")
VALUES ('001XXXXXXXXXXXXAAA','Acme Widgets','a0nYYYYYYYYYYYYAAA');
-- Insert from a SELECT
INSERT INTO "TargetTable" ("Id","Site_Contact__c")
SELECT "Id","Site_Contact__c"
FROM "Quick_Quote__c_export"
WHERE "Site_Contact__c" IS NOT NULL;
Joins
-- Inner join sample
SELECT a."Id", a."Name", q."Site_Contact__c"
FROM "Account__export" a
JOIN "Quick_Quote__c_export" q
ON q."Account__c" = a."Id"
LIMIT 50;
-- Left join sample
SELECT q."Id" AS "QuickQuoteId",
a."Name" AS "AccountName",
q."Site_Contact__c"
FROM "Quick_Quote__c_export" q
LEFT JOIN "Account__export" a
ON a."Id" = q."Account__c";
-- Create a new table from a join
CREATE TABLE "QQ_with_Accounts" AS
SELECT q."Id" AS "QuickQuoteId",
a."Name" AS "AccountName",
q."Site_Contact__c"
FROM "Quick_Quote__c_export" q
LEFT JOIN "Account__export" a ON a."Id" = q."Account__c";