Is it possible to group data in a dataset?

A

Amadelle

Hi All and thanks in advance,

I was wondering what is the best way of grouping data in a dataset. Like
using a "Group By" clause in Sql statements. I was thinking of using XML
but I don't even know how to do grouping in XML.

I have a dataset table which i would like to supposedly run the following
sql statement on:

Select UserID from tblAccounts
Group By UserID

Any ideas would be highly appreciated,

Thanks again,

Amadelle
 
P

Patrick Steele [MVP]

Hi All and thanks in advance,

I was wondering what is the best way of grouping data in a dataset. Like
using a "Group By" clause in Sql statements. I was thinking of using XML
but I don't even know how to do grouping in XML.

I have a dataset table which i would like to supposedly run the following
sql statement on:

Select UserID from tblAccounts
Group By UserID

You're not using any aggregating function (like MIN, MAX, AVG, etc...)
so why do you need the GROUP BY?
 
A

Amadelle

r u seriously asking me that question?

I don't have to have aggregate functions to use a Group by Clause.

tblAccounts
accountID userID
1 23
2 23
3 23
4 35
5 35

the group by clause that I have will return the following:

UserID
23
35

basically a user can have zero to many accounts I just want all the users in
the tblAccounts that do have accounts associated with them but i don't want
their account details.

Hope this helps you help me find a solution,

Thanks
 
P

Patrick Steele [MVP]

r u seriously asking me that question?

Yes, I am.
I don't have to have aggregate functions to use a Group by Clause.

True. But you don't need group by to do what you want.
tblAccounts
accountID userID
1 23
2 23
3 23
4 35
5 35

the group by clause that I have will return the following:

UserID
23
35

Look into SELECT DISTINCT.
 
A

Amadelle

"Distinct" statment still doens't change the fact that you don't need an
aggregate function to do "Group By".
And even with a Distinct statement my issue is still outstanding on how to
do Grouping on a dataset? In my original email I explained that I want a
"similar" functionality as what a "Group By" statement provides me with in
SQL. If there is a way to use Distinct statement on a dataset or XML, or a
dataview, I would still be happy.

So if you have a solution please let me know ...

Thanks,

Amadelle
 
P

Patrick Steele [MVP]

"Distinct" statment still doens't change the fact that you don't need an
aggregate function to do "Group By".

I never said it was needed. I asked why you felt you needed a GROUP BY
-- DISTINCT is a better description of what you want.
And even with a Distinct statement my issue is still outstanding on how to
do Grouping on a dataset? In my original email I explained that I want a
"similar" functionality as what a "Group By" statement provides me with in
SQL. If there is a way to use Distinct statement on a dataset or XML, or a
dataview, I would still be happy.

The reason I mentioned SELECT DISTINCT was because it would be easier to
let the database do their sorting/aggregating/filtering for you instead
of doing it on the client.

But anyway.... No, you can't do what you'd like with a DataSet or
DataView. Might be able to do it with XML, but I abhor XSL so don't
know how to do it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top