vb.net sql query counting

I have a sql database with 3 columns (board, line, defect)

The current sql query counts all the total amount of defects on the same board on the same line and populates a datagrid view.

        sqlCmd.CommandText = "SELECT board, count(defect) AS defect FROM [sqlccmdefects] WHERE [line] = @line GROUP BY board ORDER BY defect DESC" ' and date >= @startdata  AND date <= @enddata 

    'SQL Command Params
    sqlCmd.Parameters.Add("@line", SqlDbType.VarChar, 30).Value = mainform.line.Text
    sqlCmd.Parameters.Add("@board", SqlDbType.VarChar, 30).Value = mainform.boardname.Text

The column “defect”, has the values “contamination” or “violation”. How would i alter the query to count the amount of “contamination” against the same board and same line, i’ve searched google and the brain isnt working.


Source: sql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.