Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6589463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:10:42+00:00 2026-05-25T17:10:42+00:00

I am Beginner in Sql, I m trying SQL Group By statement, my requirement

  • 0

I am Beginner in Sql, I m trying SQL Group By statement, my requirement is below.

Table Structure  <br> 
USerID  int <br> 
BrowserName nvarchar(200) <br> 
BrowserVersion nvarchar <br> 
LoggedOntime  Time 

here is my requirement. I want select the all details based on the user id along with it should Group By Browser Name. I tried the follwing query its returining. but how to use this in visual studio to Display in Gridview as Group FOr each Browser. when the user Clicks a group in gridview it should display all details of that browser.

for eg. If i click FireFox then It should shows the detail for Firfox Group with all Version, And LoggedOnTime Details for the particular user id

select  
  BrowserName, 
  LoggedOnTime, 
  BrowserVersion
from 
  BrowserSession 
  inner join Users on UserId = Users.UsersId
where 
  UserId=21 
group by 
  BrowserName, 
  LoggedOnTime,
  BrowserVersion 
order by 
  BrowserName, 
  LoggedOnTime
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:10:43+00:00Added an answer on May 25, 2026 at 5:10 pm

    If the query is static you can do like this, otherwise you can use parameters on the query:

            SqlConnection con = new SqlConnection(connectionString);
    
            string sqlQuery = "select  BrowserName, LoggedOnTime, BrowserVersion"
                                + " from BrowserSession inner join Users on UserId=Users.UsersId"
                                + " where UserId=21 group by BrowserName, LoggedOnTime,BrowserVersion order by BrowserName, LoggedOnTime";
    
            SqlCommand cmd = new SqlCommand(sqlQuery, con);
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
    
            adapter.Fill(ds, "TableName");
    
            GridView1.DataSource = ds;
            GridView1.DataBind();
    

    Using Parameters:

            string sqlQuery = "select  BrowserName, LoggedOnTime, BrowserVersion"
                                + " from BrowserSession inner join Users on UserId=Users.UsersId"
                                + " where UserId=@userID group by BrowserName, LoggedOnTime,BrowserVersion order by BrowserName, LoggedOnTime";
    
            SqlCommand cmd = new SqlCommand(sqlQuery, con);
            cmd.Parameters.AddWithValue("@userID", 21);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL Server Beginner question: I'm trying to introduce a computed column in SQL Server
I have two columns in a SQL table, fooId (int) and fooName (varchar). Is
I am a beginner SQL user (not formally trained; OJT only) and need some
I'm a beginner with SQL and am working on one of my first databases.
i am beginner with sql, I have comments Template with button in the end
I'm pretty experienced in C#, but still mostly a beginner in SQL. We have
I'm a beginner with C#, ASP.NET, SQL Server Express and programming in general. I'm
SQL beginner here. I have a query which takes around 10 seconds to run,
I am a beginner in SQL Functions. What is the best way to create
I'm just a beginner in SQL Server database development and was wondering which authentication

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.