Belajar sepanjang hayat

Belajar dan berbagilah !, Sesungguhnya berbagi ilmu itu indah...

Jangan biarkan waktu mengalahkan anda..

Manfaatkan dengan belajar dan berbagi ilmu

Ilmu pengetahuan akan menuntun ke arah yang benar

Orang tanpa ilmu ibarat orang buta yang berjalan dalam kegelapan, tanpa arah dan tanpa penuntun..

Belajar Sepanjang Hayat

Indahnya dunia hanya dapat dinikmati oleh mereka yang berakal.

Rabu, Maret 17, 2010

How to make cross tab query in MySQL (database management)

As I wrote a script to display cross tab data (for my personal need), I searched for effective methods to get the job done. I came across many techniques that can be used to workout exactly the same job (Cross-tab). However, the simplest technique to do the job is using statement “SELECT DISTINCTROW”.


SELECT DISTINCTROW [FieldName], count([FieldName]) FROM [TableName] Group By [FieldName]

Example
SELECT DISTINCTROW stbayar , count(stbayar) as Jumlah
FROM pengunjung
GROUP BY stbayar
ORDER BY jumlah DESC

this will return

stbayar Jumlah
U 7216
J 5742
A 2987
P 1755
N 242
K 225
L 6

you might want to create your own tricks, please let me know if they work !

Keep sharing on the spirit of UBUNTU

How to make cross tab query in MySQL (database management)

As I wrote a script to display cross tab data (for my personal need), I searched for effective methods to get the job done. I came across many techniques that can be used to workout exactly the same job (Cross-tab). However, the simplest technique to do the job is using statement “SELECT DISTINCTROW”.


SELECT DISTINCTROW [FieldName], count([FieldName]) FROM [TableName] Group By [FieldName]

Example
SELECT DISTINCTROW stbayar , count(stbayar) as Jumlah
FROM pengunjung
GROUP BY stbayar
ORDER BY jumlah DESC

this will return

stbayar Jumlah
U 7216
J 5742
A 2987
P 1755
N 242
K 225
L 6

you might want to create your own tricks, please let me know if they work !

Keep sharing on the spirit of UBUNTU