473,487 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 40032
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
5283
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
9956
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
1387
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
7031
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
11904
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
3693
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
11846
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
8456
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
4879
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...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.