replacing number

Posted on 2011-05-10
Last Modified: 2012-05-11
If I have the following result of crosstab query
      Product 1      Product 2       Product 3      Product4
Customer 1            5.5            666
Customer 2      .222            454      
Customer 3      258      252            365
Customer 4                        
Customer 5      25            25      

Based on this result I would like to run another query that will leave the null value but replace the  numbers with “1”
Question by:dina78
    LVL 39

    Expert Comment

    by:Pratima Pharande
    use isnull(colname,1)

    LVL 12

    Accepted Solution

    select product1, case
    when product2 is not null then 1
    else null
    end product2
    from (
    --your old query
    LVL 31

    Expert Comment

    What dbms are you using?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
    'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now