Q:

T-SQL where statement not working

I've got the following query with across the following table structure:
select * 
from [dbo].[Interpurchase_Intervals_1] 
where client_id = '24' 

Table structure:
Client_ID nvarchar(10, null)  
Customer_ID nvarchar(max, null) 
Gradient decimal ((18,5), null)

The query:
select distinct [Client_ID] 
from [dbo].[Interpurchase_Intervals_1]

Returns:
 Client_ID
 ----------
 13   
 24   
  8

The query:
select * 
from [dbo].[Interpurchase_Intervals_1]

returns:
 classification   Client_ID 
 ----------------------------
      1              24
      2              24
      1              13

However, when I run this query:
select * 
from [dbo].[Interpurchase_Intervals_1] 
where client_id = '24' 

I get an empty result set. 
I don't see why filtering the data by client_id = '24' returns an empty dataset when it return:
 classification Client_ID 
 ------------------------
    1             24
    2             24

A:

If you have unwanted whitespace in the Client_ID column, the best thing to do would be to remove it.  If you can't do that, then one option to deal with it in your query would be to trim it away:
SELECT *
FROM [dbo].[Interpurchase_Intervals_1]
WHERE LTRIM(RTRIM(client_id)) = '24'

