Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Maximum Qty
Message
From
24/01/2019 01:57:58
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows Server 2008 R2
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01665698
Message ID:
01665699
Views:
65
Likes (1)
I could not produce the result in one single query, perhaps someone has an idea to modify to that extent. This produces an ordered list and then searches for the highest occurance.
SELECT Junk.id, Junk.qty, JunkMax.Count FROM Junk ;
    JOIN (SELECT COUNT(*) AS Count, JunkMax.Qty FROM Junk JunkMax GROUP BY JunkMax.Qty) AS JunkMax ON JunkMax.Qty == Junk.Qty ;
    ORDER BY Junk.qty desc,Count DESC
Count = Count
LOCATE FOR Count > m.Count
BROWSE
>Sir, this is my first post in levelextreme
>
>I have this data
>
>
>
>CREATE CURSOR junk(id n(3),qty n(5))
>
>INSERT INTO junk values(1,500)
>INSERT INTO junk values(2,600)
>INSERT INTO junk values(3,700)
>INSERT INTO junk values(4,700)
>INSERT INTO junk values(5,700)
>INSERT INTO junk values(6,700)
>INSERT INTO junk values(7,700)
>INSERT INTO junk values(8,700)
>INSERT INTO junk values(9,700)
>INSERT INTO junk values(10,800)
>INSERT INTO junk values(11,900)
>INSERT INTO junk values(12,1000)
>INSERT INTO junk values(13,1100)
>INSERT INTO junk values(14,1200)
>INSERT INTO junk values(15,1300)
>INSERT INTO junk values(16,1300)
>INSERT INTO junk values(17,1300)
>INSERT INTO junk values(18,1400)
>INSERT INTO junk values(19,1300)
>INSERT INTO junk values(20,1300)
>INSERT INTO junk values(21,1400)
>BROWSE
>
>
>
>I want to get data showing with arrow.
>
>
>
>
>Formula:
>
>What maximum qty is being used as maximum time?
>
>qty 1400 is maximum qty but is being used only 2 times
>qty 1300 is not maximum but it is being used 5 times.
>qty 700 is being used 7 times but it is not maximum.
>
>So I need a maximum qty with maximum times with its respective id like
>
>15, 1300
>Both conditions : maximum qty + maximum number of occurrence
>
>Here is occurrence count
>
>
>
>
>Please help me
Christian Isberner
Software Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform