I am trying to add custom attribute column in admin customer grid in Magento 2 but I got below error.
main.CRITICAL: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ip_country' in 'order clause'
if the column is an action column please add below code
<actionsColumn name="actions" class="namespace\firstname\Ui\Component\Listing\Action">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="resizeEnabled" xsi:type="boolean">false</item>
<item name="resizeDefaultWidth" xsi:type="string">107</item>
<item name="indexField" xsi:type="string">ip_country</item>
</item>
</argument>
</actionsColumn>
if this an normal column add the below code.
<column name="ip_country">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">IP Country</item>
</item>
</argument>
</column>
Try these codes and check once
Why do you need to add column programmatically when it can be managed via setting or while creating the custom customer attribute. Login to admin, Go to Stores->Attributes->Customer->search for your customer attribute and set Add to Column Options to Yes (Select "Yes" to add this attribute to the list of column options in the customer grid.)
Hope this helps!