ตัวอย่างใช้ SQL GROUP BY กับ SQL SUM

Post a reply

Smilies
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: ตัวอย่างใช้ SQL GROUP BY กับ SQL SUM

ตัวอย่างใช้ SQL GROUP BY กับ SQL SUM

by thatsawan » 20/01/2016 11:14 am

Image

Code: Select all

$sql_array = array(
            'SELECT' => 'tag_name,tag_id,SUM(num_row)',
            'FROM' => array(
                $this->table_prefix . tables::TAGS_HOT => 't'
            ),
            'GROUP_BY' => 'tag_id DESC',
            

        );
        
        $sql = $this->db->sql_build_query('SELECT', $sql_array);
        echo $sql; exit;

Code: Select all

SELECT tag_name,tag_id,SUM(num_row) FROM (phpbb_m_tag_hot t) GROUP BY tag_id DESC
Image


เพิ่มเติมได้ที่
http://www.w3resource.com/sql/aggregate ... oup-by.php

Top