Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query without max()
Message
De
14/09/2019 03:18:33
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
14/09/2019 02:55:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01670845
Message ID:
01670850
Vues:
70
J'aime (1)
>
>Thanks sir Cetin Basoz for helping but I do not want to use more than one column in group by clause.
>Is it possible to use ;with cte or some alternative method?
>
>Please

If you look at it from possibility point, yes it is possible. ie:
WITH totals (code, qty) AS 
(SELECT code, SUM(qty)
    FROM #Table1
    GROUP BY code)
SELECT t1.code, tn.Names, tn.Country, t1.qty
FROM totals t1
    CROSS APPLY (SELECT TOP (1) names, country
    FROM #Table1 t2
    WHERE t1.code = t2.code) tn(Names, Country)
ORDER BY t1.code;
Ç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