Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Max Qty
Message
From
28/02/2019 07:11:26
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01666828
Message ID:
01666838
Views:
67
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform