Please see the following example table. I would like to count the 1’s in each row. For the first row N_1 must be 3, for the second 2, then 1, then 0. In the end I would like to incorporate this into a stored procedure with the parameters Table, Columns, Value.
CREATE TABLE Have
( Col1 INT NOT NULL
, Col2 INT NOT NULL
, Col3 INT NOT NULL
, N_1 INT NULL
)
INSERT Have (Col1, Col2, Col3)
VALUES
(1, 1, 1)
,(1, 1, 2)
,(1, 2, 2)
,(2, 2, 2)
try this
or if you need to Update the table
then you can perform