You must Sign In to post a response.
  • Category: SQL Server

    How to replace NULL value by 0 in PIVOT result

    Hi,

    I want to replace NULL values by 0 in the PIVOT result

    Thanks & Regards
    RK
  • #762949
    try

    SELECT isnull(col,0) *
    FROM
    (
    SELECT
    Studentname, Subject, Marks
    FROM StudentDetails
    ) as s
    PIVOT
    (
    SUM(Marks)
    FOR [Subject] IN (Physics,Chemistry,Maths)
    )
    AS Pivot_alias

    for more details

    http://dotnetmentors.com/sql/how-to-pivot-data-in-sql-server.aspx

    Laxmikant


Sign In to post your comments