Question : Filtering MS SQL cross-tab query

I have the below query for MS SQL database running at compatibility level 80 on MS SQL 2005 which returns results as shown in sample below. I would like to filter out of this result set, any rows that are null for BOTH Pounds Sterling AND Euro. Rows that have one or the other of these two values should show along with the USD value, but removed if BOTH are null.

I am only interested in the rows that have BOTH a Pounds Sterling AND Euro value. So, given the below sample, only row 2 (57-271) should be dropped from result set.

Thanks.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
SELECT stock_number,  
       p.itemid,       
       MAX(CASE WHEN p.pricegroup = 6 THEN price ELSE null END) 'Pounds Sterling',    
       MAX(CASE WHEN p.pricegroup = 10 THEN price ELSE null END) 'Euro', 
       MAX(CASE WHEN p.pricegroup = 2 THEN price ELSE null END) 'USD' 
 FROM iod_pricing p  
 INNER JOIN IOD_Items i ON p.itemid = i.itemid   
 WHERE p.pricegroup IN (2,6,10)  
 AND usergroupid = 0  
 GROUP BY stock_number, p.itemid, description  
 ORDER BY i.stock_number

-------------------------------------------------------------
stock_number	Itemid	Pounds Sterling	Euro	USD
57-264	15688	127.5	219.23	219.23
57-271	15680	NULL	NULL	500
57-287	15708	2141.75	NULL	521
57-288	15709	NULL	520	123
57-289	15710	637.5	670	NULL
57-291	15712	637.5	820	820

Answer : Filtering MS SQL cross-tab query

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
select * from  
( 
SELECT stock_number,    
       p.itemid,         
       MAX(CASE WHEN p.pricegroup = 6 THEN price ELSE null END) 'Pounds Sterling',      
       MAX(CASE WHEN p.pricegroup = 10 THEN price ELSE null END) 'Euro',   
       MAX(CASE WHEN p.pricegroup = 2 THEN price ELSE null END) 'USD'   
 FROM iod_pricing p    
 INNER JOIN IOD_Items i ON p.itemid = i.itemid     
 WHERE p.pricegroup IN (2,6,10)    
 AND usergroupid = 0    
 GROUP BY stock_number, p.itemid, description    
) a 
where ([Pounds Sterling] is null and [Euro] is not null) or  ([Pounds Sterling] is not null and [Euro] is null)
ORDER BY stock_number
Random Solutions  
 
programming4us programming4us