Solved

Finding the max entered in the fields

Posted on 2007-11-26
8
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

Author Comment

by:FIATECH
ID: 20352473
well i don't want to pull the whole column. only those 6 values from that column.
0
 
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

688 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