Performance of Query where time captured from SP statement completed differs by large from RPC completed I am unable to understand the performance of below query when collected data from XE events:

Query

DECLARE @Importdate DATETIME = ISNULL ((

SELECT ImportDatetime
FROM
Customertable
where CustomerID = 1
and OrderID =1 
) , '01/01/2000')


This part of statement returns just 1 row


  SP statement completed shows 40 secs
  
  RPC Completed for above statement shows 64 secs


Need help to understand why RPC will show such a big difference and where to look for this problem ? 
I do not see any NW issue reported as such but what does this indicate here and query as simple as above seems to high for that run time

Please advice
Generally speaking rpc_completed includes network time, while sp_statement_completed does not.  This is very likely the case for your query, since it only returns one row.

So one explanation is the extra time is spent sending data over the network to the client.

You could try measuring wait statistics for this query to confirm there are 24 seconds of ASYNC_NETWORK_IO waits that explain the difference.  

If the server has SSMS installed, you could remote desktop into it and run the query there, which should have very little network wait time.  In which case you'd see very little difference in the time on those two events for this statement.