The ISNULL( ) function is used to replace NULL value with another value.
For example, if we have the following table,
Table-- Students
Student_Name Maths Physics
Student A 300 NULL
Student B NULL NULL
The following SQL,
we will get as
300
300
******what is the purpose of using Isnull( ) ?
Thanks
For example, if we have the following table,
Table-- Students
Student_Name Maths Physics
Student A 300 NULL
Student B NULL NULL
The following SQL,
SELECT SUM (ISNULL(Maths,100)) as MathsTotal FROM Student;
returns the following result: 400
This is because NULL has been replaced by 100 via the ISNULL function, so the total becomes 300 + 100 = 400.
2.select ISNULL(physics,200)+ISNULL(maths,100) from students
2.select ISNULL(physics,200)+ISNULL(maths,100) from students
we will get as
300
300
Let me know if you have any doubts on this.
******what is the purpose of using Isnull( ) ?
Thanks
GSV
No comments:
Post a Comment