Salesforce Decode
Salesforcedecode
SOQL & Data ModelingBeginnerDebuggingsoqlexceptionsdebugging

What causes "List has no rows for assignment to SObject" and how do you avoid it?

Scenario

Code like Account a = [SELECT Id FROM Account WHERE Name = :n]; fails in production.

Answer it out loud first

Serious prep means attempting before reading. Take two minutes to structure your answer, then compare.