Querynya seperti ini:
SELECT tjabar.BahanAktif AS BAjabar, tjabar.Aplikasi AS APjabar,
tjateng.BahanAktif AS BAjateng, tjateng.Aplikasi AS APjateng FROM
(SELECT bahan_aktif AS BahanAktif, SUM(jml_applikasi) AS Aplikasi
FROM pesticide INNER JOIN pesticide_visit
ON pesticide.nama = pesticide_visit.pesticide_nama
WHERE farmer_id LIKE '11%'
GROUP BY BahanAktif ORDER BY Aplikasi DESC
LIMIT 3) AS tjabar,
(SELECT bahan_aktif AS BahanAktif, SUM(jml_applikasi) AS Aplikasi
FROM pesticide INNER JOIN pesticide_visit
ON pesticide.nama = pesticide_visit.pesticide_nama
WHERE farmer_id LIKE '12%'
GROUP BY BahanAktif ORDER BY Aplikasi DESC
LIMIT 3) AS tjateng
keluarnya 9 baris:
BAjabar APjabar BAjateng APjateng
Mancozeb 838 Mancozeb 278
Methomyl 693 Mancozeb 278
Dimehipo 394 Mancozeb 278
Mancozeb 838 Chlorpyrifos 252
Methomyl 693 Chlorpyrifos 252
Dimehipo 394 Chlorpyrifos 252
Mancozeb 838 Methomyl 241
Methomyl 693 Methomyl 241
Dimehipo 394 Methomyl 241
padahal yang diinginkan hanya 3 baris dari masing2 tjabar dan tjateng..
Please advise..
Thanks
----- Original Message -----
From: Ferry Setiawan
To: [email protected]
Sent: Wednesday, November 29, 2006 4:22 PM
Subject: RE: [indo-oracle] Query keluar cartesian
field key nya apa?
contoh data?
relasinya 1 to 1 atau n to m?
> Dear masters,
>
> Mo nanya query ini,
>
> SELECT A.X, B.Y FROM A, B;
>
> Apakah memang keluarnya kombinasi dari setiap rows di table A
> dengan setiap rows di table B?
>
> Jadi kalo A.X ada 5 baris, dan B.Y ada 3 baris, hasilnya 15 baris..
>
> bagaimana supaya keluarnya 5 baris aja (field B.Y kosong 2 baris)?
>
> Thanks in Advance,
> Oscar
------------------------------------------------------------------------------
This message contains confidential information and is intended only for the
individual named. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and delete
this e-mail from your system. E-mail transmission cannot be guaranteed to be
secure or error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. MKD Group therefore
does not accept liability for any errors or omissions in the contents of this
message, which arise as a result of e-mail transmission. If verification is
required please request a hard-copy version.
MKD Group, www.mkdgroup.com
------------------------------------------------------------------------------
[Non-text portions of this message have been removed]