We help IT Professionals succeed at work.

need to remove null values from the below query in sqlserver2005

mu_ravi1
mu_ravi1 asked
on
387 Views
Last Modified: 2012-05-11
Hi
pls provide me query for the beolw
write a query to remove null value follwing table?
col1   col2   col3
dinesh null   null
null   suresh  null
null   null    prakesh

i want the output

col1     col2   col3
dinesh  suresh  prakesh
Regards
Ravi
Comment
Watch Question

Alpesh PatelSolution Architect at TCS (SAFe®Agilist, TOGAF® Foundation, PSM I®, MCP, MCSD)
CERTIFIED EXPERT

Commented:
What should be the output is source is like below:


col1   col2   col3
dinesh null   alpesh
null   suresh  null
null   null    prakesh
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Sharath SData Engineer
CERTIFIED EXPERT

Commented:
do you need this?
select max(col1) col1,max(col2) col2,max(col3) col3
  from your_table

Open in new window

Author

Commented:
PatelAlpesh

yes  i want the source like that.
Ravi

Commented:
You can do something like this


SELECT 
(SELECT col1 FROM tablename WHERE col1 IS NOT NULL),
(SELECT col2 FROM tablename WHERE col2 IS NOT NULL),
(SELECT col3 FROM tablename WHERE col3 IS NOT NULL)

Open in new window

Author

Commented:
good
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.