Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL to retrieve maximum value from a row.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00305138
Message ID:
00305324
Vues:
14
Martin,

Make the date field a datetime field, don't worry about the number of records there will be. The time you spend making the change will be far outweighted by the improvement of the ease of analyzing the data later.

Besides the time it would take to write a UDF, to compare the fields in the record to get the highest one and then do the same to all records for the same date and then finally compare the highest time for each record for the date and get the highest of those, far outweights the time involved in running a query. Also, you can anticipate that requests will arrive on your desk for;

  • The average time for each half hour interval for a date period
  • The average value for the entire date
  • The lowest value of a given day
  • The lowest value for a date period
  • The standard deviation of values for a particular half hour across a period of dates.
  • etc. etc. etc.

    The change in structure that I am recommending will make it easy to provide any one of those reports and dozens of others that I can't even think of right now. Why you may ask?

    The answer is really rather simple, the entity that is needed here is the value for a half hour. That's what should be recorded by the table, that is what the current question is asking, "What is the highest halfhour value for a given date?"

    The current structure for your table is recording Values for a date. So to answer a question about values for a halfhour you have to write code to convert the data from values for a date to values for a halfhour.
  • Précédent
    Répondre
    Fil
    Voir

    Click here to load this message in the networking platform