473,387 Members | 1,757 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,387 software developers and data experts.

How to find out Minimum of numbers in rows of a table

17
Thanks a lot

I will try your suggestions after a while but there is one another question -

I have a table having fields as - num1, num2, num3 and num4

I have a query named "MinimumNum"

Now in the calculated field of query "MinimumNum" - how can i get the minimum of num1, num2 num3, num4

please help me - i used - Minmum: DMin( num1, num2, num3, num4) - but it does not work.

please help me

thanks in advance
Sep 14 '06 #1
5 3126
PEB
1,418 Expert 1GB
Hi,

Use select query and press the sigma bouton for SUm!

So in the group by fill Min under every numeric field!

:)
Sep 14 '06 #2
mukesh
17
Hi,

Use select query and press the sigma bouton for SUm!

So in the group by fill Min under every numeric field!

:)
Thanks for your answer and support - but I need a formula for calculated field in a query which automatically selects minimum number amongst the numbers in more than one "row" (not a column) of a table

please help.
Sep 14 '06 #3
PEB
1,418 Expert 1GB
So for you I've developped this function:

You introduce like a SQL parameter a query on which you would like to find the minimum between columns, also introduce the start column with numeric data to be compared and the end column! Between the columns you have to have only numeric fields that have to be compared!

The function returns only the first line! So in your SQL supply only one line!

:)
Expand|Select|Wrap|Line Numbers
  1. Function min_in_columns(SQL, Start_col, End_col) As Double
  2. Dim mydb As Database
  3. Dim myr As Recordset
  4. Dim i
  5. Dim min_value
  6.  
  7. Set mydb = CurrentDb()
  8. Set myr = mydb.OpenRecordset(SQL)
  9.  
  10. min_value = 0
  11.  
  12. myr.MoveFirst
  13. For i = Start_col To End_col
  14.     If min_value > myr(i) Then
  15.         min_value = myr(i)
  16.     End If
  17. Next i
  18. myr.Close
  19. mydb.Close
  20.  
  21. min_in_columns = min_value
  22. End Function
  23.  
Sep 14 '06 #4
mukesh
17
So for you I've developped this function:

You introduce like a SQL parameter a query on which you would like to find the minimum between columns, also introduce the start column with numeric data to be compared and the end column! Between the columns you have to have only numeric fields that have to be compared!

The function returns only the first line! So in your SQL supply only one line!

:)
Expand|Select|Wrap|Line Numbers
  1. Function min_in_columns(SQL, Start_col, End_col) As Double
  2. Dim mydb As Database
  3. Dim myr As Recordset
  4. Dim i
  5. Dim min_value
  6.  
  7. Set mydb = CurrentDb()
  8. Set myr = mydb.OpenRecordset(SQL)
  9.  
  10. min_value = 0
  11.  
  12. myr.MoveFirst
  13. For i = Start_col To End_col
  14.     If min_value > myr(i) Then
  15.         min_value = myr(i)
  16.     End If
  17. Next i
  18. myr.Close
  19. mydb.Close
  20.  
  21. min_in_columns = min_value
  22. End Function
  23.  
Is this a module? How shoud i use it

I have save it as 'module1' and in the calculated field of query table typed - Min: min_in_columns ([numer1], [number2], [number3])

but when i open the query, it opens the module automatically.

I do not know how to write module and how to refere the same in query to work it.

please help me. You are too intelegent to help me, i know it.
Sep 15 '06 #5
PEB
1,418 Expert 1GB
Hi,

You have done well that you saved this code in a module...

Before save it go in Debug or Run I don't remember more and choose the commande Compile module...

If there is no errors so the function is ok...

And then you need to use it in your query...

So imagine

Your table with numbers is named My_numbers and has the folloing columns:

ID - Your primary key of your table
Description - Text field that has no importance for our numbers
Numb1 - your first number
Numb2 - your Second number
.......
Numb32

And you need to see the minimum of your 32 fields isn't it?

So in your query
In the Field row type:

Wanted_Minimum:min_in_columns("SELECT * FROM My_numbers WHERE ID=" & STR([ID]), 2, 33)

NOTE: YOUR NUMBERS ARE ONE AFTER ONE IN YOUR SQL!!! THERE IS NO NOTHING EXCEPT THE WANTED NUMBERS THAT PARTICIPATE IN THE MINIMUM!

Have a nice day!

:)
Sep 16 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: SQLJunkie | last post by:
Here is an issue that has me stumped for the past few days. I have a table called MerchTran. Among various columns, the relevant columns for this issue are: FileDate datetime , SourceTable...
6
by: JJA | last post by:
I would like some advice on a data and query problem I face. I have a data table with a "raw key" value which is not guaranteed to be valid at its source. Normally, this value will be 9 numeric...
3
by: RobG | last post by:
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,...
3
by: Solel Software | last post by:
Hello, I have a basic question. I have a DataTable of information without a database store (it's only in memory). I am looking to somehow query the DataTable to find out which row(s) satisfy...
67
by: PC Datasheet | last post by:
Transaction data is given with date ranges: Beginning End 4/1/06 4/4/06 4/7/06 4/11/06 4/14/06 4/17/06 4/18/06 4/21/06 426/06 ...
4
by: Randy | last post by:
Hi, I have a table which contains a unique value in a column called "Idx", which is a smallint data type. I need to find the maximum value in this column, which I have been attempting to do with...
2
by: cshaw | last post by:
Hello Everyone, I am having problems with a listbox control. I have a page with a couple of labels and drop-down lists at the top, and then below there is a table with two columns, the first column...
11
by: zj262144 | last post by:
Hi, I'm a C beginner. I want to write a C. The pseudocodes are like this: User enters some numbers (use -1 to end) The compiler find and delete the maximum and minimum numbers Then average...
19
by: fera | last post by:
Hi to all of you guys here… A friend of mine gave me: 1). A paper with a table of 350 rows x 284 columns, which each cell contains of a single number from 0 to 9. This table didn’t typed yet into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.