| Author |
Message |
slamet_linux |
| Location: |
|
Post subject: Query
Posted: 07/May/2008 13:05
|
|
onIntermediate

Joined: 15-Feb-2007
Posts: 50
Status: Offline
|
|
rekan rekan mau tanya :
klo misalnya ada table :
//Table Master
Nomor
Tanggal
Kode1
//Table Detail
Nomor
Kode2
Harga
Jumlah
Total
//////////////////////////////////////////////////////////////+
// Nomor :
// Tanggal :
// Kode1 :
//
//------------------------------------------------------------
// NOmor | Kode2 | Harga | Jumlah | Total
//------------------------------------------------------------
//
//
//
//
//
//------------------------------------------------------------
// Total
//
///////////////////////////////////////////////////////////////
statement sql nya gimana ya ? supaya hasilnya :
|==============================+
| Nomor | Tanggal | Total |
|==============================+
| xxxx | yyyyyy | zzzzzzz |
| xxxx | yyyyyy | zzzzzzz |
|==============================+
select a.Nomor, b.Tanggal, ....
from Table1 a, table2 b
where a.Nomor = b.Nomor
order by Nomor
tararengkyu |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: 07/May/2008 13:18
|
|
onElite

Joined: 09-Oct-2005
Posts: 1313
Location: BeDeGe
|
|
|
|
|
 |
herux |
| Location: Kediri |
|
Post subject:
Posted: 07/May/2008 13:42
|
|
onProfessional
Joined: 13-Jul-2006
Posts: 668
Location: Kediri
Status: Offline
|
|
| kalo susah ya pake query tool khan banyak tuh !! |
|
|
| |
|
|
|
 |
Alfando |
| Location: |
|
Post subject:
Posted: 07/May/2008 13:51
|
|
onConfident

Joined: 28-Apr-2008
Posts: 28
Status: Offline
|
|
apa maksutnya mau nampilkan total nomer per tanggal?
select a.Nomor, b.Tanggal, count(a.Nomor)
from Table1 a, table2 b
where a.Nomor = b.Nomor
order by Nomor
sori kalau salah |
_________________ SUGALI, tak seperti yang kau duga
|
| |
|
|
|
 |
Alfando |
| Location: |
|
Post subject:
Posted: 07/May/2008 13:55
|
|
onConfident

Joined: 28-Apr-2008
Posts: 28
Status: Offline
|
|
select a.Nomor, b.Tanggal, count(a.Nomor) Total
from Table1 a, table2 b
where a.Nomor = b.Nomor
order by Nomor |
_________________ SUGALI, tak seperti yang kau duga
|
| |
|
|
|
 |
slamet_linux |
| Location: |
|
Post subject:
Posted: 07/May/2008 14:36
|
|
onIntermediate

Joined: 15-Feb-2007
Posts: 50
Status: Offline
|
|
|
ImanD wrote:
xixixi mo jawab apa ya, bingung ini pertanyaan dah ke jawab apa emang maksudnya gwe ga ngerti,
coba sample datanya skalian bro
(
itu yang .... (titik - titik) itu pa, kan itu :
select a.Nomor, b.Tanggal, ....
from Table1 a, table2 b
where a.Nomor = b.Nomor
order by Nomor
itu yang titik titik kan (sum(total) from Table2 where Nomor = :Nomor) biar jadi satu gimana ? |
|
|
| |
|
|
|
 |
Wong_Jowo |
| Location: |
|
Post subject:
Posted: 07/May/2008 15:06
|
|
onConfident
Joined: 13-Nov-2007
Posts: 27
Status: Offline
|
|
mm... mas slamet mbingungi banget loh,,,
code : pascal select b.nomor,a.tanggal,sum(b.total) from table1 a, table2 b where a.nomor = b.nomor group by b.nomor order by b.nomor;
|
|
|
| |
|
|
|
 |
slamet_linux |
| Location: |
|
Post subject:
Posted: 07/May/2008 16:17
|
|
onIntermediate

Joined: 15-Feb-2007
Posts: 50
Status: Offline
|
|
|
Wong_Jowo wrote:
mm... mas slamet mbingungi banget loh,,,
code : pascal select b.nomor,a.tanggal,sum(b.total) from table1 a, table2 b where a.nomor = b.nomor group by b.nomor order by b.nomor;
ok pa, satu pertanyaan lagi, klo misalnya yang di table detail itu field total nya tidak hanya satu misal total1, total2, total3, dst.... gimana query nya ya ?
code : pascal select b.nomor,a.tanggal,sum(b.total1, b.total2 ) from table1 a, table2 b where a.nomor = b.nomor group by b.nomor order by b.nomor;
kan ga bisa ? |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: 07/May/2008 16:25
|
|
onElite

Joined: 09-Oct-2005
Posts: 1313
Location: BeDeGe
|
|
|
|
|
 |
Wong_Jowo |
| Location: |
|
Post subject:
Posted: 07/May/2008 16:28
|
|
onConfident
Joined: 13-Nov-2007
Posts: 27
Status: Offline
|
|
bisa kan...
group nya berdasarkan b.nomor, jadi dijumlahkan yang nomornya sama
code : pascal select b.nomor,a.tanggal,sum(b.total1) as total1, sum(b.total2) as total2 from table1 a, table2 b where a.nomor = b.nomor group by b.nomor order by b.nomor;
|
|
|
| |
|
|
|
 |
Wong_Jowo |
| Location: |
|
|
Post subject:
Posted: 07/May/2008 16:31
|
|
onConfident
Joined: 13-Nov-2007
Posts: 27
Status: Offline
|
|
walah lebih cepetan mas iman
kalah cepet dah nyonge |
|
|
| |
|
|
|
 |
slamet_linux |
| Location: |
|
Post subject:
Posted: 07/May/2008 16:33
|
|
onIntermediate

Joined: 15-Feb-2007
Posts: 50
Status: Offline
|
|
|
ImanD wrote:
[sql:1:9a15014412]
select b.nomor, a.tanggal, sum(b.total1), sum(b.total2)
from table1 a, table2 b
where a.nomor = b.nomor
group by b.nomor
order by b.nomor;
[/sql:1:9a15014412]
coba klo gini
maksudnya sum nya itu adalah hasil sum(b.total1), sum(b.total2) dan seterusnya
seandainya bisa -> sum(sum(b.total1), sum(b.total2), dst....) |
|
|
| |
|
|
|
 |
slamet_linux |
| Location: |
|
Post subject:
Posted: 07/May/2008 16:38
|
|
onIntermediate

Joined: 15-Feb-2007
Posts: 50
Status: Offline
|
|
|
Wong_Jowo wrote:
walah lebih cepetan mas iman
kalah cepet dah nyonge
he... he... tenang pa, masih belon habis... masih ada tuh... |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: 07/May/2008 16:56
|
|
onElite

Joined: 09-Oct-2005
Posts: 1313
Location: BeDeGe
|
|
|
slamet_linux wrote:
maksudnya sum nya itu adalah hasil sum(b.total1), sum(b.total2) dan seterusnya
seandainya bisa -> sum(sum(b.total1), sum(b.total2), dst....)
ya tinggal di tambah az ko di buat susah, xixiixx
[sql:1:09dd8da70c]
select b.nomor, a.tanggal, sum(b.total1)+sum(b.total2) +..... AS TotalKabeh
from table1 a, table2 b
where a.nomor = b.nomor
group by b.nomor
order by b.nomor;
[/sql:1:09dd8da70c] |
_________________
website: http://darusmanaiman.net/
e-mail:
darusmanaiman@programmer.net
programmer@darusmanaiman.net
|
| |
|
|
|
 |
ichan29 |
| Location: |
|
Post subject:
Posted: 08/May/2008 09:00
|
|
onProfessional
Joined: 23-Feb-2007
Posts: 603
Status: Offline
|
|
|
Quote:
ya tinggal di tambah az ko di buat susah, xixiixx
tambahin bro.. gitu aja kok repot.. ala gusdur
cuman skrip itu hanya bisa jalan di mySQL keliatannya ya.. tp klo di MSSQL keliatannya ada kendala di [sql:1:7ac2811c38]GROUP By b.nomor[/sql:1:7ac2811c38] bener ngga ya |
|
|
| |
|
|
|
 |
|
|