1
Hi,
Happy to see, it solved your problem.
To get count of distinct values in a row, you can use below code -
int countDepInvo = table.AsDataView().ToTable(true, "depInvo").Rows.Count;
Please mark it as answer, if the solution was helpful to you as it helps others with same problem!
0
<h4 style="outline: none 0px; color: #333333; font-family: "Open Sans", sans-serif; font-size: 14px; background-color: #ffffff;"><a data-userid="9088f9" href="http://www.c-sharpcorner.com/members/midhun-tp" style="outline: none 0px; none; cursor: pointer; font-weight: normal; font-family: Roboto, sans-serif; color: #ff6600;">Midhun T P</a></h4><div>Thank you, this solved the problem but</div><div>i want to retrieve count of a column with distinct records how to get that. </div><div>i mean can i do this by c# or by sql statement like.</div><div></div><div>I mean can i get DISTINCT values from this C# statement:</div><div><div class="dp-highlighter"><div class="bar"></div><ol start="1" class="dp-c"><li class="alt"><span><span>countDepInvo=table.Compute(</span><span class="string">"Count(depInvo)"</span><span>,</span><span class="string">""</span><span>);</span></span></li></ol></div></div><div></div>
0
If the above query is part of stored procedure, you can have another query below this and handle multiple result sets in your data access layer in C#.
If you are using SQL Server 2012 and above, you can use advance windowing functions to get the sum in the same row and pick the value only from the last row.
Or make a separate db call just for the sum.