SQL help

Kasun k

Well-known member
  • Mar 11, 2009
    10,357
    492
    83
    United States
    මචං group by එකේදී හැම select statement එකකටම වෙන වෙනම අදාල වෙන whare clause යූස් කරන්න පුලුවනිද? එහෙම පුලුවන්නම් නියමයි. මොකද මම දැන් කරල තියෙන විදියෙන් එන්නේ ලිස්ට් එකක්. column විදියට එනවනම් column name එකට refer කරල value එක ගන්න පුලුවන්. දැන් මම කරල තියෙන්නේ. මගේ කස්ටම් array එකක් එක්ක result array එක මෙන්න මේ විදියට array_combine($keys, $values); කම්බයින් කරල අරන් තියෙන්නේ. මමත් මේකට එච්චර කැමති නෑ මොකද field keys array එකක් hardcode කරන්න වෙන නිසා. :sorry:

    Group By ake select statement godak one na. AKai one. Ara Sample akak dala thibba kawda. Ahema karanna. Naththan oyage data sample aka post karanna.
     

    3rdEye

    Member
    Mar 21, 2014
    4,465
    401
    0
    මේක කරා නම් ඔය තරම් නටන්න ඕන නැහැ මන් හිතන විදියට :P:P

    thoge vote eka gaagan puke wesige putha.ida rep ponnaya.kotawala athal ganna ponna pakaya.original eken warenko

    :sorry::confused::nerd::(

    යකෝ මුන් කිසිම අදාළ නැතුවම රෙෆ් කපලනේ :angry::angry:
     
    • Like
    Reactions: NO_MeRcY

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    Union danna one na. mechcharai tiyenne karanna.
    http://sqlfiddle.com/#!9/e2ede/2

    bump dbms

    yeah, meka group by use karanna oni query ekak, ey me union dagena dangalanne kiyala therenne ne.

    This is the correct answer. Not some Union workaround.

    Group By ake select statement godak one na. AKai one. Ara Sample akak dala thibba kawda. Ahema karanna. Naththan oyage data sample aka post karanna.

    Meka mama mulin dapu query ekamay. See the result
    http://sqlfiddle.com/#!9/e2ede/5

    Wena wenama where clauses one nam
    http://sqlfiddle.com/#!9/e2ede/14

    :sorry::confused::nerd::(

    යකෝ මුන් කිසිම අදාළ නැතුවම රෙෆ් කපලනේ :angry::angry:


    මචංලා තෑන්ක්ස් රිප්ලයි වලට. මේකයි ප්‍රශ්නේ මට COUNT, SUM වගේ ඇග්රිගේට් ෆන්ක්ෂන් වලට අමතරව WHERE CLAUSE පවා යූස් කරන්න වෙනව වෙන වෙනම එක් එක් SELECT එකට උදාහරණයක් විදියට.

    select COUNT(country) AS customer_count_ina_country1 from customers where country = srilanka;
    මේ ඒ වගේම තවත් select query එකක්. මේ හැම select එකක්ම වෙන වෙනම field විදියට එනවනම් සුපිරි.
    select COUNT(country) AS customer_count_ina_country2 from customers where country = usa;
    select COUNT(country) AS customer_count_ina_country3 from customers where country = uk;
    select COUNT(country) AS customer_count_ina_country4 from customers where country = china;

    GROUP BY එක්ක අපිට where එක අපිට අන්තිමේදි නේ යූස් කරන්න වෙන්නේ ඒක හරියන්නෑ වගේ. ඒත් මම හරියමට දන්නෑ. මට ඕන එක් එක් select එකට වෙන වෙනම where clause භාවිතා කරන්න. :D