Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL SELECT Statement - Problem with Field Definition Cha
Message
De
08/12/1998 10:32:00
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00165075
Message ID:
00165087
Vues:
11
>I program for an iron foundry. I have a table that has daily data entered into it for the weight of each ladle of molten metal that has been poured in the foundry. Some of the weights are identical. For example, today there may be 2 ladles weighing 1873 lbs each, and 3 ladles weighing 1902 lbs each, etc. For EACH ladle that is poured, a record is entered into the table; so that, for the 2 ladles of 1873 lbs mentioned above, you would have 2 individual records stating a Qty of 1, and a Weight of 1873 lbs.
>
>I am attempting to use an SQL SELECT statement to gather this data, GROUP the identical weights together, add up (COUNT) the quantities for records with identical weights, and then write these records INTO another TABLE. Once these these records are tabulated in this fashion, I then wish to turn around and APPEND these records into a permanent history file called Ladles_d.dbf.
>
>Here's the SQL SELECT statement I'm using...
>
>SELECT prodline, dept, date, year, period, COUNT(ladlesqty), weight FROM LdlInput.dbf WHERE Weight <> 0 GROUP BY Weight ORDER BY Weight INTO TABLE LdlData.dbf
>
>This works beautifully with the following exception...
>
>The field definition for the ladlesqty field (the field on which the COUNT is performed) gets changed in the target LdlData table...
>
>
>Fieldname gets changed from ladelsqty to cnt_ladles
>Width changes from Numeric 6 to Numeric 10
>
>
>When I then try to APPEND FROM LdlData into Ladles_d.dbf, the permanent history file (which has the same structure as the daily entry table, LdlInput.dbf), all the fields come across except for the ladlesqty field.
>
>Obviously, this makes my effort totally useless as I lose the quantity of ladles poured. Any help would be greatly appreciated as I am about to pull my hair out at this point. Thanks, CWH.

It seems to me, that you actually want to use SUM instead of count:
SELECT prodline, dept, date, year, period, 000000+SUM(ladlesqty) AS ladlesqty, weight FROM LdlInput.dbf WHERE Weight <> 0 GROUP BY Weight ORDER BY Weight INTO TABLE LdlData.dbf

'000000'-will provide needed field length
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform