HiI am looking at work created by a previous developer and wonder why they would do this with a view. First they have created a view like this:CREATE VIEW MyView AS select isnull(Col1,'') as Col1 ,isnull(Col2,'') AS Col2 ,isnull(Col3,'') AS Col3 ,isnull(Col4,'') AS Col4 ,COALESCE(SUM(Col5), 0) as Col5 ,ISNULL(Col6,'') AS Col6 FROM Table1 Group By Col1 ,Col2 ,Col3 ,Col4 ,Col5 ,Col6 GO
Then after that they have:select isnull(Col1,'') as Col1 ,isnull(Col2,'') AS Col2 ,isnull(Col3,'') AS Col3 ,isnull(Col4,'') AS Col4 ,COALESCE(SUM(Col5), 0) as Col5 ,ISNULL(Col6,'') AS Col6 FROM MyView Group By Col1 ,Col2 ,Col3 ,Col4 ,Col5 ,Col6 GO
Note: I put the coalesce in as part of some upgrading work.And the only difference I can see is the select from the view returns 2 less rows than the actual select from the table used to create the view.I'm really not sure why someone would do this and what it would achieve, and can't figure out why the select from the view is 2 less rows than the table select, I didn't think it would make any difference.ThanksG