asp.net - Select Distinct and Count in Grid View -


i need help....

this example of database table:

record_id    user_id    record ------------------------------- 001          a111111    file1 002          a111111    fileq 003          a222222    file2 004          a222222    file3 005          a111111    file4 006          a333333    file5 007          a333333    file6 

i want show in grid view below:

user_id    total_record ----------------------- a111111         3 a222222         2 a333333         2 

select count(*) total_record table user_id

i know sql syntax don't know how create grid view show result query please me

your sql little off, going need group user_id. i've included code sqldatasource , gridview below, modified sql. of course, you'll need set connectionstring data source.

    <asp:sqldatasource runat="server" id="dsmysource"         selectcommand="select user_id, count(*) total_record mytable group user_id">     </asp:sqldatasource>     <asp:gridview runat="server" id="gvcount" datasourceid="dsmysource" autogeneratecolumns="false">         <columns>             <asp:boundfield headertext="user_id" datafield="user_id" />             <asp:boundfield headertext="total_record " datafield="total_record" />         </columns>     </asp:gridview> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -