Skip to main content

cara mengetahui top product(e-commerce)

6 replies [Last post]
does not have a status.
adietz89's picture
User offline. Last seen 17 weeks 2 days ago. Offline
Joined: 05/02/2011

mau nanya nih ..sya sedang bkin e commerce... nah buat bkin top product gmana ya...maksudnya product yang bnyak dijual...querynya gmana ya bingung...mohon bantuannya...
ni struktur database nya

tabel orders:
1. orders_id
2. Username
3. tgl_pemesanan
4.status pemesanan

tabel orders_detail:
1. id_orders_detail
2. orders_id
3. product_id
4. jumlah_pembelian..

cara mengetahui product yang banyak dijual?.....

now... what????
zawaruddin's picture
User offline. Last seen 1 week 3 days ago. Offline
Joined: 02/28/2011
oh yadah.. coba pakai yg ini,

oh yadah.. coba pakai yg ini, moga bener n bisa membantu.
Ane cuma ngira2, ni query di postgre, moga aja bisa d db u jg.

select product_id, sum(jumlah_pembelian) as total from order_detail group by product_id order by total desc

------------------------------------------------------------
Go..Go..Go.. CodeIgniter

Visit My Blog @ zawaruddin.blogspot.com

does not have a status.
adietz89's picture
User offline. Last seen 17 weeks 2 days ago. Offline
Joined: 05/02/2011
cihuy...

cihuy.... berhasil boss thanks bgt atas bantuannya kerjaan ane jd lancar nih.... lain kali sya nanya2 jgn bosen ya..hhe

eh mas klo pake active record gmana ya...maklum baru pake CI harap di maklumi...

does not have a status.
predhtz's picture
User offline. Last seen 2 weeks 13 min ago. Offline
Joined: 01/07/2010
$this->db->select

$this->db->select ("product_id, sum(jumlah_pembelian) as total");
$this->db->group_by("product_id");
$this->db->order_by("sum(jumlah_pembelian)");
return $this->db->get("order_detail");

does not have a status.
adietz89's picture
User offline. Last seen 17 weeks 2 days ago. Offline
Joined: 05/02/2011
makasih boss...

makasih boss...

now... what????
zawaruddin's picture
User offline. Last seen 1 week 3 days ago. Offline
Joined: 02/28/2011
CMIIW

coba pake ini

select product_id, max(jumlah_pembelian) from order_detail group by product_id

hasil dari query tersebut akan menampilkan tiap product_id yg jumlah_pembeliannya terbanyak.Klo ingin dijumlah, ganti aja MAX dengan SUM.

ane masih kurang paham, ma pertanyaan ente, produk yg banyak dijual tuh perproduk atau gmn?
jadinya ane cm ngasih query yg keak gitu... hehe

------------------------------------------------------------
Go..Go..Go.. CodeIgniter

Visit My Blog @ zawaruddin.blogspot.com

does not have a status.
adietz89's picture
User offline. Last seen 17 weeks 2 days ago. Offline
Joined: 05/02/2011
maksudnya perproduk mas....

maksudnya perproduk mas.... jadi buat nampilin barang2 yang banyak di jual ... bgitu mas...

jadi kira2 hasil outputnya

produk 1 = 100
produk 2 = 99
produk 3 = 88
dst......

di ranking gt mas...

Premium Drupal Themes by Adaptivethemes