You might come across a requirement where you have to get the instance name of the organisation.
In that case we can make use of one of the setup object in Salesforce and get access to the instance name.
This is how the query is gonna look like to get the instance name.
String instanceName = [SELECT InstanceName FROM Organization LIMIT 1].InstanceName;
Learn it by building it
Every course, every code repository, the discussion group and certificates of completion — one subscription.