Hi there,
DECLARE
@tmp TABLE(NameCHAR(30),balancechar(6), tpk INT,TypeVARCHAR(10),DescrCHAR(40),FieldCHAR(50))
INSERT
@tmp SELECT 'Leigh', 43.20, 12345 ,'272' , 'Sales', ''
INSERT
@tmp SELECT 'Leigh', 43.20, 12345 ,'289' , 'Mortgagee', 'BANK'
INSERT
@tmp SELECT 'Logan', 54.87, 55322 ,'null' ,'', ''
INSERT
@tmp SELECT 'Simon', 28.67, 44433 ,'272' ,'Sales',''
INSERT
@tmp SELECT 'Stew', 10.18, 44422 ,'null' ,'', ''
INSERT
@tmp SELECT 'Tim' , 24.30, 33322 , '272' , 'Sales', 'BANK'
INSERT
@tmp SELECT 'Tim' , 24.30, 33322 , '289' , 'Mortgagee', 'BANK'
INSERT
@tmp SELECT 'Chris' , 68.22, 34567, '289' , 'Mortgagee', 'BANK'
gives me the answer
Leigh 43.20 12345 272 Sales
Leigh 43.20 12345 289 Mortgagee BANK
Logan 54.87 55322 null
Simon 28.67 44433 272 Sales
Stew 10.18 44422 null
Tim 24.30 33322 272 Sales BANK
Tim 24.30 33322 289 Mortgagee BANK
Chris 68.22 34567 289 Mortgagee BANK
What I am trying to achieve here is this, if it is type 289, 272 or null seperately then it shows.
However I have 2 rows which have got data types 272 and 289 and I only want to bring back 289. How can I do this without not losing the null values. As I know I could do a where statement to only seek '289' and null values, but there are some records showing with 272 only. So I am trying to get the to look like this
Leigh 43.20 12345 289 Mortgagee BANK
Logan 54.87 55322 null
Simon 28.67 44433 272 Sales
Stew 10.18 44422 null
Tim 24.30 33322 289 Mortgagee BANK
Chris 68.22 34567 289 Mortgagee BANK
Cheers