Jump to content

sql طريقة استخراج القيم بالترتيب من الاكبر للأصغر [طلب]


Recommended Posts

السلام عليك

ابي كيف استخرج القيم من الاكبر للأصغر من عمود في قواعد البيانات

اعرف استخرج القيم لكن ابيها تكون من الاكبر للأصغر

ونفس الشي على الجداول

زي توب الفلوس والتواجد وكنق الدرفت

Link to comment
table.sort 

ادري بس ما فهمت

شف محاولتي

وتراني ملخبط بام الكود

local Query = executeSQLQuery("SELECT * FROM PointsDerby") 
if ( Query and type ( Query ) == "table" and #Query ~= 0 ) then 
table.sort(Query, function(a,b) return (tonumber(a.points)or 0) > (tonumber(b.points)or 0) end) 
for i,v in ipairs ( points ) do  
outputChatBox(v) 
end 
end 

ذا السطر جبته من موت توب درفت وعدلته

table.sort(Query, function(a,b) return (tonumber(a.points)or 0) > (tonumber(b.points)or 0) end) 

اذا فيه تخويش والا شي عطني خبر عشن اباشر عملي

:lol:

Link to comment
  
addEventHandler ( "onResourceStart", resourceRoot, function() 
    executeSQLQuery ("CREATE TABLE IF NOT EXISTS PointsDerby (acc,points)") 
end) 
  
local Query = executeSQLQuery("SELECT * FROM PointsDerby") 
if ( Query and type ( Query ) == "table" and #Query ~= 0 ) then 
table.sort(Query, function(a,b) return (tonumber(a.points)or 0) > (tonumber(b.points)or 0) end) 
for i,v in ipairs ( points ) do  
outputChatBox(v) 
end 
end 

Link to comment

local Query = executeSQLQuery("SELECT * FROM PointsDerby") 
    if ( Query and type ( Query ) == "table" and #Query ~= 0 ) then 
        table.sort(Query, function(a,b) return (tonumber(a.points)or 0) > (tonumber(b.points)or 0) end) 
            for i,v in ipairs ( Query ) do 
                outputChatBox( v.acc .. ' : '.. v.points ) 
    end 
end 
Link to comment
local Query = executeSQLQuery("SELECT * FROM PointsDerby") 
    if ( Query and type ( Query ) == "table" and #Query ~= 0 ) then 
        table.sort(Query, function(a,b) return (tonumber(a.points)or 0) > (tonumber(b.points)or 0) end) 
            for i,v in ipairs ( Query ) do 
                outputChatBox( v.acc .. ' : '.. v.points ) 
    end 
end 

ياعيني ياعيني شكرا

يعني طريقتي كانت صح بس ناقصه

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...