Solved

Finding the max entered in the fields

Posted on 2007-11-26
8
161 Views
Last Modified: 2010-04-06
Ok, I have 6 numeric textfields. I want to display the max of the 6 fields. How can I do this? The only appraoch I had in mind is with a list, but I know there's another way. maybe a quesry loop on the 6 fields to find the max? HELP
0
Comment
Question by:FIATECH
  • 4
  • 4
8 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 20352411
Can you give an example of what you mean with the desired results?
0
 

Author Comment

by:FIATECH
ID: 20352434
yes. <cfoutput>#biggestnumber#</cfoutput>

if 10, 89, 35, 3, 5, 78 was entered I just want to get the saved result in the DB to display. SO maybe I can pull those variables from the DB and just show the max? Its sounds so easy but I can't do it!
0
 
LVL 52

Expert Comment

by:_agx_
ID: 20352453
If they values are entered into a column named "ColumnA" you could just use MAX

<cfquery name="yourQuery" ...>
SELECT MAX(ColumnA) AS biggestnumber
FROM   YourTable
</cfquery>

<cfoutput>#YourQuery.biggestnumber#</cfoutput>
0
 

Author Comment

by:FIATECH
ID: 20352473
well i don't want to pull the whole column. only those 6 values from that column.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 52

Expert Comment

by:_agx_
ID: 20352499
How do you identify the 6 values, by ID or are they stored as a comma delimited list, or something else?  In other words what is a sample of the table data you're using?
0
 

Author Comment

by:FIATECH
ID: 20352516
I want these only form the table

<cfset A_day04_3=getdata.A_day04_3>
<cfset A_day05_2=getdata.A_day05_2>
<cfset A_day10_4=getdata.A_day10_4>
<cfset A_day11_3=getdata.A_day11_3>
<cfset A_day12_2=getdata.A_day12_2>
<cfset A_dayothe=getdata.A_dayothe>
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 20352615
One option is use a union query

<cfquery name="getBiggestNumber" ...>
  SELECT  Max(TheNumber) AS BiggestNumber
  FROM  (
  SELECT A_day04_3 AS TheNumber FROM YourTable
  UNION
  SELECT A_day05_2 AS TheNumber FROM YourTable
  UNION
  SELECT A_day10_4 AS TheNumber FROM YourTable
  UNION
  SELECT A_day11_3 AS TheNumber FROM YourTable
  UNION
  SELECT A_day12_2 AS TheNumber FROM YourTable
  UNION
  SELECT A_dayothe AS TheNumber FROM YourTable
  ) AS t
</cfquery>

Another is to put the values into an array and use arrayMax

<cfset list = "#getdata.A_day04_3#,#getdata.A_day05_2#,#getdata.A_day10_4#,#getdata.A_day11_3#,#getdata.A_day12_2#,#getdata.A_dayothe#">
<cfset biggestnumber = arrayMax(listToArray(list))>
<cfoutput>
#biggestNumber#
</cfoutput>



0
 

Author Comment

by:FIATECH
ID: 20352634
Thanks I like the list array! THANKS! Let me try it now!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now