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

Get the maximum value of a row

I have a recordset that is comprised of several columns of data. Most of the columns refer to a 15 min increment of each day. I need to be able to find the value that is used the most for each day. I am using ASP for the page and SQL to create the recordset.

Here is an example of data:

EFFDATE T_0000 T_0015 T_0030 T_0045 ..... T_1145
10/27/2008 ASW ASW BRK CAT ASW

For 10/27/2008, I need to return ASW, since it is the most used value. Any suggestions on how to achieve this?

Thank you in advance for any help with this issue.
Oct 27 '08 #1
5 1475
JamieHowarth0
533 Expert 512MB
Hi there,

The better way of storing this data would be to create a single table which has the following columns - EFFDATE (as you currently use it), TIME (to store the 4-digit time you choose) and VALUE (to store ASW values).
In this way, you could use the following SQL code:
Expand|Select|Wrap|Line Numbers
  1. SELECT EFFDATE, COUNT(VALUE), VALUE FROM myTable
  2. GROUP BY EFFDATE, VALUE
  3. ORDER BY COUNT(VALUE)
  4.  
This would then pull off the following:
[EFFDATE] | [Expr1000] | [VALUE]
10/27/2008 | 3 | ASW
10/27/2008 | 1 | BRK
10/27/2008 | 1 | CAT

If you changed the SELECT to SELECT TOP 1 you'd then get the maximum value, or just ASW, which is what appears to be your ideal solution.

Hope this helps.

codegecko
Oct 27 '08 #2
Thank you very much for your response. Unfortunately, I don't believe I would be able to change the actual table. Is there a way to create a dynamic table, using the data as it is currently stored, and converting it to the way you describe it? Which would only be used for my application? In the meantime, I will attempt to sway my boss, to allow the table to be changed, which is most likely a "NO!" : )

Thanks again!
Oct 27 '08 #3
JamieHowarth0
533 Expert 512MB
Hi there,

What database engine are you using - Access, Microsoft SQL Server, MySQL etc.?
If you're using Microsoft SQL Server 2005 there's a handy SQL function called PIVOT - or, as you've mentioned, creating a temporary table to hold the manipulated results, but I'd need to confirm it's SQL Server you're using to be able to produce some useful code.

codegecko
Oct 28 '08 #4
the database is oracle 10g.

thanks!!
Oct 28 '08 #5
i have been able to get the data into a string using the EFFDATE and values of each of the times when they are not null. Is there a way to count the different values and return the max? Here is the code and the output I have to this point:
--------------
while not rsTblEmpCalendar.EOF = true
for each myField in rsTblEmpCalendar.Fields
if myField.value <> "" then
strFieldValue = strFieldValue & myField.Value & ", "
end if
next
rsTblEmpCalendar.movenext
wend
--------------
10/27/2007, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, 1/5/2008, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, BRK, ASW, ASW, ASW, MTG, MTG, MTG, MTG, MTG, BRK, BRK, BRK, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, MTG, MTG, MTG, 10/15/2008, ASW, ASW, ASW, ASW, MTG, MTG, MTG, MTG, BRK, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, BRK, BRK, MTG, MTG, MTG, ASW, ASW, BRK, BRK, ASW, ASW, ASW, MTG, ASW, ASW, ASW, BRK, CAT, CAT, CAT, ASW, 10/21/2008, ASW, ASW, ASW, ASW, MTG, MTG, MTG, MTG, BRK, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, BRK, BRK, ASW, ASW, MTG, MTG, MTG, BRK, BRK, MTG, ASW, ASW, ASW, MTG, ASW, ASW, BRK, ASW, ASW, ASW, ASW, 10/23/2008, ASW, ASW, ASW, ASW, MTG, MTG, MTG, MTG, BRK, ASW, ASW, ASW, ASW, ASW, ASW, ASW, ASW, BRK, BRK, ASW, ASW, ASW, ASW, BRK, ASW, MTG, ASW, MTG, MTG, ASW, ASW, ASW, BRK, ASW, ASW, ASW, ASW,
--------------
Thank you for all of your help!!
Oct 28 '08 #6

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

Similar topics

10
by: KemperR | last post by:
Dear All, may be some of you can help me with an XSLT example how to solve the following challange. For the XML below I want to find out the maximum hierarchy level for a specific element in my...
2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
2
by: MrNobody | last post by:
I have been struggling with .NET's scrollbars because when I use them I can't seem to get them to go to their maximum value. Searching on the web it looks like the maximum Value you can get on...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
3
by: Madmartigan | last post by:
Hello I have the following task but am battling with the final output. How do I keep two different vectors in sync and how would I retrieve the index for the maximum value of one of the vectors??...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using the VScrollBar and set it as follow: m_vScrollBar.Minimum = -19602; m_vScrollBar.Maximum = 0; m_vScrollBar.SmallChange = 1; m_vScrollBar.LargeChange = 1089; m_vScrollBar.Value =...
1
by: maurizio | last post by:
thank you for your answer actually i've to do some statistics (maximum,minimum,mean,standard deviation,....) of a file of data in which each column is a particular type of data. (the file is a tab...
7
by: laredotornado | last post by:
Hi, I'm using PHP 5 with MySql 5. I have a MySQL InnoDB table with a column of type INTEGER UNSIGNED. Is there a constant in PHP to insert the maximum value possible into the column? The...
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...
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.