Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comparing entire record
Message
De
15/10/1999 08:13:45
 
 
À
13/10/1999 12:51:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00275358
Message ID:
00276753
Vues:
25
Outstanding. Thanks.

>>I should have provided a better explanation. Frankly, the subject is incorrect too. It should read: "Comparing almost an entire record."
>>
>>I am familiar with the DISTINCT clause and use it for similar cases. I prefer SELECT - SQL in general and I could use it in this case but I think it would be burdensome. Interesting that you mention it because recently I have used the DISTINCT clause to solve a similar problem in a very complex problem. It is convenient. I don't think I like it for large tables though.
>>
>>Here's a try at a better explanation. Keep in mind that the records have many more fields than this simple example.
>>
>>The table appears like this sample:
>>
>>(REC NO) YEAR MAKE MODEL
>>1 1990 Ford Escort
>>2 1991 Ford Escort
>>3 1992 Ford Escort
>>4 1980 Chevy Blazer
>>5 1981 Chevy Blazer
>>6 1990 Chevy Blazer XT
>>7 1995 Honda Civic
>>
>>I am instructed to build a table from the above table that would look like this:
>>
>>BEG_YEAR END_YEAR MAKE MODEL
>>1990 1992 Ford Escort
>>1980 1981 Chevy Blazer
>>1990 Chevy Blazer XT
>>1995 Honda Civic
>>
>>I feel that looping is the way to go but I am querying the good folks on the UT for different methods too. Anyway I am looping on the table and if any value changes (except year) I build a record in the new table. I manage the various variables appropriately and can build the new table without difficulty. However, it seems burdensome for me to track *every* field (except year) for two records so I can determine if there is a change.
>>
>>The example may not be the best choice but I think it works for demonstrating the concept I am facing.
>>
>>Thanks.
>>
>>>I'm not sure I understand your question but this may help. A SELECT - SQL with the DISTINCT clause will weed out complete record duplicates and you can choose which fields are in the SELECT. Also look at the UNION clause as it will remove duplicates from the result set unless the ALL keyword is used with UNION.
>>>
>>>>I have been directed to generate a special table from an existing table. Each record has a year value in it. The new table should display one record with a year range (e.g. Beg_year field and End_year field) if all fields except year are identical. I have done this fairly easily but I suspect there may be a better method.
>>>>
>>>>With the table indexed appropriately, I loop through the database and compare the fields from one record to the next and store the year values in appropriate
>>>>variables. If there is a change in any field other than the year field, then
>>>>I write a record to a second table with the year range and other values.
>>>>
>>>>The comparison of one record to the next is fairly burdensome. Is there a way to compare entire records more easily? Is there an entirely different method that would be more effective?
>>>>
>>>>Thanks.
>
>How about:
>
>SELECT MIN(Year),MAX(Year),Make,Model FROM table GROUP BY Make,Model ... ?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform