Hello,

I have a dataset that has rows with data that are all different. In some of
the rows the "DescID" and "PlaceID" are the same, but primarilly they are
all different. What I am trying to do is group all the rows that have the
same DescID and PlaceID. If there are multiple rows with these two colomns
being the same I need the Quantity Field to be increased by 1.

IE

ID DescID PlaceID Quantity
1 34D 81C 1
2 36P 81C 1
3 34D 81C 1
4 32F 14T 1

This should be the result after grouping them

ID DescID PlaceID Quantity
1 34D 81C 2
2 36P 81C 1
3 32F 14T 1

Any suggestions will be greatly appreciated. The data will be saved to a
SQL Database after this is accomplished.

Thanks,
Chuck

Re: Grouping?? by Adrian

Adrian
Tue Aug 30 21:10:51 CDT 2005

Charles,

This article might help:

HOW TO: Implement a DataSet GROUP BY Helper Class in Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;326145

But if you want to write or maintain less code, you might be interested in
the assembly I've been workingIt lets you perform complex SQL SELECT
statements including UNION, JOINS, GROUP BY, HAVING, ORDER BY, sub-queries,
etc against the tables in a dataset.

In your case,

Dataset ds; // you dataset populated with the data below
DataView dv = QueryADataset.DsCommand.Execute("select descid, placeid,
count(quantity) from yourtable group by descid, placeid", ds);
// then the dataview can be written to the database

Hope this helps
Adrian Moore
http://www.queryadataset.com
Peersoft


"Charles A. Lackman" <Charles@CreateItSoftware.net> wrote in message
news:uokNiabrFHA.3852@TK2MSFTNGP15.phx.gbl...
> Hello,
>
> I have a dataset that has rows with data that are all different. In some
> of
> the rows the "DescID" and "PlaceID" are the same, but primarilly they are
> all different. What I am trying to do is group all the rows that have the
> same DescID and PlaceID. If there are multiple rows with these two
> colomns
> being the same I need the Quantity Field to be increased by 1.
>
> IE
>
> ID DescID PlaceID Quantity
> 1 34D 81C 1
> 2 36P 81C 1
> 3 34D 81C 1
> 4 32F 14T 1
>
> This should be the result after grouping them
>
> ID DescID PlaceID Quantity
> 1 34D 81C 2
> 2 36P 81C 1
> 3 32F 14T 1
>
> Any suggestions will be greatly appreciated. The data will be saved to a
> SQL Database after this is accomplished.
>
> Thanks,
> Chuck
>
>