Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select with Group by and Order by
Message
De
28/04/2010 14:43:18
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 6 SP5
Divers
Thread ID:
01462119
Message ID:
01462385
Vues:
31
>>>No, I see the same, but what is the question then? We do indeed have just one N record for master_Code 3 or master_Code 4 and that's what my query is returning - no argument here.
>>>
>>>In other words, my query will return number of Ys if we have at least one Y and number of other Master_Ind if we have them and don't have 'Y'.
>>>It would not return the total number of records per Master_Code, if this was your point.
>>
>>You are playing with words. He had only one Y per master_code and he wanted to have the count of rows per master_code, not a constant 1 per master_code. See his original question where I replied with a 2 part SQL.
>>Cetin
>
>This query will return only records that have at least one 'Y' with the correct number of records per them:
>
>select MAX(name) as Name, COUNT(*) as CntRecs, MAX(Master_Ind) as Index1, Master_Code from @C T1
>group by master_code  
>having sum(case when Master_Ind = 'Y' then 1 end) > 0
>
>but it seems that the problem is a problem of returning the correct values for the aggregated column and I'm afraid there may be no simple 1 select-SQL solution for VFP6. In VFP9 this problem can be easily solved using derived table approach.


"I'm afraid there may be no simple 1 select-SQL solution for VFP6. In VFP9 this problem can be easily solved using derived table approach." That is it. Thanks for repeating me:)

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform