| Author |
Topic |
|
sweet_777
Starting Member
16 Posts |
Posted - 2010-10-06 : 23:42:50
|
| Hi all,i my table dept, 2 columns are there. 1.email 2.fax. 3.moduleemail, fax , modulecontactemail , contactfax , DEstudymanageemail , managefax , DEaddemail , addfax , DEsiteemail , null , DEmonitoremail , null , DEi have written query like this :SELECT email,fax from dept where module='DE' I AM getting all values but i don't want null values.email , fax contactemail , contactfax studymanageemail , managefax addemail , addfax siteemail , null monitoremail , null i want o/p like this:email , fax contactemail , contactfax studymanageemail , managefax addemail , addfax siteemail , monitoremail Regards RamaThanks & RegardsSweet_77 |
|
|
razeena
Yak Posting Veteran
54 Posts |
Posted - 2010-10-07 : 00:38:43
|
| You can replace null with some other value using isnull checking...declare @test table(email varchar(20),fax varchar(10),module varchar(10))insert into @test select 'contactemail' , 'contactfax' , 'DE' union all select 'studymanageemail' , 'managefax' , 'DE' union all select 'addemail' , 'addfax' , 'DE' union all select 'siteemail' , null , 'DE' union all select 'monitoremail' , null , 'DE'select email,fax from @test where module='DE'select email,isnull(fax,0)as fax from @test where module='DE' |
 |
|
|
sql-programmers
Posting Yak Master
190 Posts |
Posted - 2010-10-07 : 00:45:11
|
| I don't know what you are expecting.But try this,Case 1:SELECT coalesce(email,'') as email,coalesce(fax,'') as fax from dept where module='DE'Case 2:SELECT email from dept where module='DE' and not(email is null)union SELECT fax from dept where module='DE' and not(fax is null)SQL Server Programmers and Consultantshttp://www.sql-programmers.com/ |
 |
|
|
|
|
|