Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Max Qty
Message
De
28/02/2019 07:11:26
 
 
À
28/02/2019 01:42:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01666828
Message ID:
01666838
Vues:
68
>Sir While using SQLSERVER 2012, I have this data
>
>
>CREATE CURSOR table1(id n(3),qty n(5))
>
>INSERT INTO table1 values(1,500)
>INSERT INTO table1 values(2,600)
>INSERT INTO table1 values(3,700)
>INSERT INTO table1 values(4,3500)
>INSERT INTO table1 values(5,900)
>INSERT INTO table1 values(6,1200)
>INSERT INTO table1 values(7,1300)
>INSERT INTO table1 values(8,1500)
>INSERT INTO table1 values(9,1700)
>INSERT INTO table1 values(10,1800)
>
>INSERT INTO table1 values(11,1900)
>INSERT INTO table1 values(12,2000)
>INSERT INTO table1 values(13,2500)
>INSERT INTO table1 values(14,1600)
>INSERT INTO table1 values(15,1000)
>
>
>I Want to get maximum qty from the last 5 rows
>
>I need this row
>
>13 2500
>
>Please

Does "last 5 rows" mean the 5 with the highest IDs? If so, something like:
SELECT * FROM Table1
   WHERE Qty = (SELECT MAX(Qty) FROM Table1 
          WHERE ID IN (SELECT TOP 5 ID FROM Table1))
Tamar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform