473,407 Members | 2,359 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,407 software developers and data experts.

Sort/find minimum value in row entries

I would like a query that will tell me the minimum non-zero value in a
row.

Say I have a table with a column called recordID that contains unique
record IDs, and have a set of values named V1, V2 up to V9 that I want
to find the minimum value for each record. The values are decimal
floating point numbers, some of the columns contain zeros but I want to
ignore those and get the minimum non-zero number.

I know how to do column sorting, but doing it for the values in a row
has me stumped.

Can someone provide a starting point?
--
Rob
Nov 13 '05 #1
3 9058
Access does not do this, because ultimately it's a bad data design.

You can write your own function to do this. The example below chooses the
largest from any number of items passed in. Easy enough to modify it to give
you the smallest.

Function Largest(ParamArray varValues()) As Variant
Dim i As Integer 'Loop controller.
Dim varMax As Variant 'Largest value found so far.

varMax = Null 'Initialize to null

For i = LBound(varValues) To UBound(varValues)
If IsNumeric(varValues(i)) Then
If varMax >= varValues(i) Then
'do nothing
Else
varMax = varValues(i)
End If
End If
Next

Largest = varMax
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RobG" <rg***@iinet.net.auau> wrote in message
news:IL*****************@news.optus.net.au...
I would like a query that will tell me the minimum non-zero value in a
row.

Say I have a table with a column called recordID that contains unique
record IDs, and have a set of values named V1, V2 up to V9 that I want
to find the minimum value for each record. The values are decimal
floating point numbers, some of the columns contain zeros but I want to
ignore those and get the minimum non-zero number.

I know how to do column sorting, but doing it for the values in a row
has me stumped.

Can someone provide a starting point?
--
Rob

Nov 13 '05 #2
Allen Browne wrote:
Access does not do this, because ultimately it's a bad data design.
Access does not implement any functionality that might be useful for
solving issues of 'bad data design'? Altruism knows no bounds! ;-)

You can write your own function to do this. The example below chooses the
largest from any number of items passed in. Easy enough to modify it to give
you the smallest.

[...]

Thanks, your help is greatly appreciated.
--
Rob
Nov 13 '05 #3
RobG wrote:
I know how to do column sorting, but doing it for the values in a row
has me stumped.


On my site, under Code Modules, there is an explanation on field sorting.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Porthos | last post by:
Hi All, I'm trying to find the minimum value of a set of data (see below). I want to compare the lengths of these attribute values and display the lowest one. This would be simple if I could...
29
by: pradt | last post by:
This might be a silly question. I'm searching for a trick to prgramatically find minimum of two positive integers without using a conditional statement/operator('if', '?', etc).
5
by: Bas Wassink | last post by:
Hi there, I was wondering what the standard (C89) states what the minimum value of FOPEN_MAX should be? K&R just state that FOPEN_MAX is implementation-defined and when googling for an answer I...
6
by: max sharma | last post by:
Hi all, I am using hashtable in C# with keys of type string and values of type double. I am not able to find a way to sort them by value (descending to be precise) instead of key. Can someone...
1
by: alan_conoco | last post by:
Hello all, I have a table looks like this in Access Product Sale Date A date A date A date B date B ...
2
by: Ros | last post by:
Peeps, I need help with trying to find a value in array of arrays. Public Module myModule Private Site_Access() As Array Property Set_SA() Get Return Site_Access End Get
1
by: umeshdchaudhari | last post by:
fist I filled value of drow down and GridView control. Now we find the databound of grid view control as per drow down value at time binding. ? How we find the value of control time of binding in...
5
by: omar999 | last post by:
hi - im trying to return the minimum value from selected columns. however for some non obvious reason it only works when 3digit long numbers are entered in to the columns in question. the below...
1
by: peachdot | last post by:
hi, i used min() to find the minimum value of an array/list. it gives the min value of each row. But how do i know in which column does the min value is..? a=for j in range(4)] a= a= a= a=
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.