I have 3 tables: Entry
, User
, Comment
. I am showing the comment count and user (sender) full name for each entry by an sql view. But when I am using a where
clause it's giving an error.
My SQL View is like:
CREATE VIEW [dbo].Entry_View
AS SELECT
E.Id AS [Id],
Convert(varchar(10), E.Date, 104) AS [Date],
E.Subject AS [Subject],
E.Content AS [Content],
E.Faculty AS [Faculty],
E.Category AS [Category],
(U.Firstname + ' ' + U.Lastname) AS [User],
E.Department AS [Department],
E.ViewCount AS [View],
E.SupportCount AS [Support],
Count(C.Entry_Id) AS [Comment]
FROM (Entry E INNER JOIN User U ON U.Id = E.User_Id)
LEFT JOIN Comment C on C.Entry_Id=E.Id
GROUP BY
E.Id, E.Date, E.Subject, E.Content,
E.Faculty, E.Category, (U.Firstname + ' ' + U.Lastname),
E.Department, E.ViewCont, E.SupportCount
When I am calling: SELECT * FROM Entry_View WHERE E.Department = 'Administration'
I am getting an error: The multi-part identifier "E.Department" could not be bound.
I couldn't solve this problem and need help. Thanks.