Solved

Finding the max entered in the fields

Posted on 2007-11-26
8
165 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 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