473,225 Members | 449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 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 40011
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jason | last post by:
I have a complex statement that is used in a SELECT statement. After all my calculations I need to do an additional filter on the results. Can I use an alias anywhere or is the AS clause just for...
6
by: Steven An | last post by:
Howdy, I need to write an update query with multiple aggregate functions. Here is an example: UPDATE t SET t.a = ( select avg(f.q) from dbo.foo f where f.p = t.y ), t.b = ( select sum(f.q)...
1
by: Job Lot | last post by:
Is it possible to use Aggregate functions with GROUP BY Clauses on DataTable. I have a DataTable with following values: Date Amount Int Balance 1/1/2004 5000.00 50.00 5050.00...
2
by: jc | last post by:
Hi. Just as we have AVG(COLUMN_NAME) and MAX(COLUMN_NAME) how can I write my own variation of a such a function. If I can appreciate how to do this, then I hopefully I can write a...
10
by: neb | last post by:
Dear member of the forum, Ms access has built-in aggregate function like: -Sum, Max, First, Avg, ... Is it possible to build user-defined aggregate? (if you have any clue, do not hesitate to...
5
by: David Garamond | last post by:
What do people think of adding some more aggregate functions. These are the ones that MySQL has and PG doesn't: - STD/STDDEV - VARIANCE - BIT_OR - BIT_AND - GROUP_CONCAT (for strings, added...
1
by: munglet | last post by:
In a DataTable Select() method can I wrap the column name with a sql function like LOWER()? The manner in which I tried failed. For example, the code below does a simple Select to get an array...
5
by: Dean | last post by:
Has anyone toiled with creating/using alternate domain aggregate functions? I have been messing with that a little. The one recordsource I have been working indicates I get 20 to 40% savings in...
3
by: gobwash | last post by:
Do aggregate functions (sum, count, min, max) inherently cause table locks? More concretely, would the following query typically result in a table lock? select sum(quantity) as total from...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.