471,316 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

Aggregate Functions in DataTable.Select

Hi NG!
With a Inner-Join SQL I get my datas in a DataSet.
In the table are the column Entry and Version.

Like this:

Entry Version
1 1
1 2
1 3
2 1
3 1
Now i would like to have just the newest version of each entry.
Entry Version
1 3
2 1
3 1

I tried to use the
DataTable.Select(MAX(Version), Entry)...
DataTable.Select(MAX(Version) GROUP BY Entry)...

But it does not work and I did not find some good help.
I would like the keep my Inner Join SQL without this MAX and Group by,
because of use in other locations

Thanks
Regards
Jan 5 '06 #1
2 39817
Hi,

I tried to use the
DataTable.Select(MAX(Version), Entry)...
DataTable.Select(MAX(Version) GROUP BY Entry)...

The DataTable/DataView is not a SQL engine therefore you cannot use TSQL .

In your particular case, it's stated in the MSDN that there will be not
group by feature, but all the rows will have the same value (when using an
aggregate)

why don't you do this in the SQL server? , frankly I think it's the only
solution.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 5 '06 #2
| I tried to use the
| DataTable.Select(MAX(Version), Entry)...
| DataTable.Select(MAX(Version) GROUP BY Entry)...
Have you tried DataTable.Compute?

http://msdn.microsoft.com/library/de...mputetopic.asp

NOTE: You will need to manually do the Group By, I normally scan the first
table, building a second table with all the unique groupings. For each
unique group I would use DataTable.Compute on the first table with the
unique group as part of the filter...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Marcel Hug" <ma******************@ATch.abb.com> wrote in message
news:u6**************@TK2MSFTNGP14.phx.gbl...
| Hi NG!
| With a Inner-Join SQL I get my datas in a DataSet.
| In the table are the column Entry and Version.
|
| Like this:
|
| Entry Version
| 1 1
| 1 2
| 1 3
| 2 1
| 3 1
|
|
| Now i would like to have just the newest version of each entry.
| Entry Version
| 1 3
| 2 1
| 3 1
|
| I tried to use the
| DataTable.Select(MAX(Version), Entry)...
| DataTable.Select(MAX(Version) GROUP BY Entry)...
|
| But it does not work and I did not find some good help.
| I would like the keep my Inner Join SQL without this MAX and Group by,
| because of use in other locations
|
| Thanks
| Regards
|
|
Jan 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by David Garamond | last post: by
1 post views Thread by munglet | last post: by
3 posts views Thread by gobwash | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.