question

JeffStiegler-8414 avatar image
0 Votes"
JeffStiegler-8414 asked Viorel-1 answered

How to get distinct counts in vb.net

How do I get a distinct count using the code below:

   Command1.CommandText = "SELECT Count(account_no) FROM fphistory " &
                                 "WHERE arr_date <= '12/31/2021'"
    
         Try
             Invoke(Sub() Total = Convert.ToInt32(Command1.ExecuteScalar))
         Catch SqlExceptionErr As SqlException
             MessageBox.Show(SqlExceptionErr.Message)
         End Try

Any help would be appreciated.

dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
2 Votes"
Viorel-1 answered

If you need a count of distinct numbers, then try 'SELECT Count(distinct account_no) FROM ...'.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.