I'm working with SQL Server and I want to create a view (my_View
) which has these columns :
[element_1]
[element_2]
[element_3]
[element_4]
All of them are referring to the same column, named [parent_1]
, in another table (AT)
[parent_1]
can have 4 possible values [value_1], [value_2], [value_3] and [value_4].
What I want is that, using COUNT
,
- [element_1] is equal to the number of times that [parent_1] is equal to [value_1]
- same for [element_2], [element_3] and [element_4] equals to [value_2], [value_3] and [value_4].
Is it possible to use "==" inside the COUNT to see if it checks the criteria?
Something like this:
COUNT (AT.parent_1 == "value_1") AS element_1
COUNT (AT.parent_1 == "value_2") AS element_2
COUNT (AT.parent_1 == "value_3") AS element_3
COUNT (AT.parent_1 == "value_4") AS element_4
Thanks guys