Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Set relationship
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01593576
Message ID:
01593712
Vues:
27
>I ran the two bottom selects and saved them to tables: T1 and T2. And the following now works! Thank you! This is a big
>shift for someone who was firmly wedded to set relation, etc.
>
>
>select  ;
>NVL(T1.RatingMax,0) + NVL(T2.RatingMAX,0) as SumMAXs, ;
>NVL(T1.yyMMddhh, T2.yyMMddhh)  AS yyMMddhh	;
>FROM;
>T1	 ;
>FULL JOIN  ;
>T2	;
>ON T1.yymmddhh = T2.yymmddhh
>
>
>Is there a way to make the output look like this, that is to include the columns for the corresponding maxes for T1 and T2.
>I tried adding in fields to my two bottom selects, but when I try, it isn't working, maybe because there is a MAX in there
>and also a GROUP BY?
>
>
>TheDate  MaxT1  MaxT2  SumMAXs
>201301    2.5       1.3        3.8
>
>
>this produces an error, for example
>
>
														
>select  ;
>mRating			,;  && tried to add in the mRating field, so it would be in the result
>MAX(mRating) 	as RatingMAX					,;
>substr(CAST(mIndex as C(14)),1,6) as yyMMddhh	;
>from tab1 					;
>GROUP BY 3  && tried to change this to 3 since want to group on 3rd column which is yyMMdd?					
>
>
>This works:
>
>
>select  ;
>MAX(mRating) 	as RatingMAX					,;
>substr(CAST(mIndex as C(14)),1,6) as yyMMddhh	;
>from tab1 					;
>GROUP BY 2
>
Your last question doesn't have much sense since you're selecting maximum rating. Which rating do you want to see in addition to that?

Do you want to see the date and hour and minute when that max rating was achieved? This would make more sense but the query will be a bit more complex.

I would go with the composed column solution for this case, e.g.
select max(mRating) as MaxRating,
RIGHT(max(cast(mRating as C(20)) + CAST(mIndex as C(14))),14) as WhenMaxRatingHappened,
LEFT(CAST(mIndex as C(14)),6) AS YearMonth
FROM Tab1
GROUP BY 3
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform