Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 22-10-2005, 02:45 PM
spicy_girl's Avatar
Novice Webmaster
 
Join Date: Jul 2003
Location: aku org malaysia...
Posts: 45
Rep Power: 0
spicy_girl is on a distinguished road
Question SQL question

Saya ada satu problem ngan sql yg dh sy buat ni :

SELECT DISTINCT PA08DOCUMENTNO,PA08DATEPOST,PA08LEDGERCODE,PA33DES CRIPTION,SUM(PA08DTAMOUNT)AS TOTALDEBIT,SUM(PA08KTAMOUNT)AS TOTALKREDIT FROM PA08LEDGER,PA02ITEMBILL,PA33ACCTCHARTDETAIL GROUP BY PA08LEDGERCODE,PA08DATEPOST,pa02subptjcode,pa02ptj code,pa02invno,pa08documentno,pa02receiptno,pa33ac countcode,pa33mainacctcode,pa33description HAVING ((PA08DATEPOST BETWEEN '"+tarikhawal+"' AND '"+tarikhakhir+"') OR (pa08datepost='"+tarikhhariini+"') OR (pa08datepost LIKE '__/"+bulan+"/2005') or (pa08datepost LIKE '______"+tahun+"')) and pa02ptjcode='"+ptj+"' and pa02subptjcode='"+subptj+"' and((pa08documentno=pa02invno) or (pa08documentno=pa02receiptno)) and ((substr(pa08ledgercode,1,4)=pa33mainacctcode) and ((substr(pa08ledgercode,5,2)=pa33accountcode or substr(pa08ledgercode,5,8)=pa33accountcode)))"; // String sql = "SELECT DISTINCT PA08DATEPOST,SUBSTR(PA08LEDGERCODE,1,4)||SUBSTR(PA 08LEDGERCODE,7,8)AS ACCOUNTNO,pa33description,SUM(PA08DTAMOUNT)AS TOTALDEBIT,SUM(PA08KTAMOUNT)AS TOTALKREDIT FROM PA08LEDGER,pa02itembill,pa33acctchartdetail GROUP BY PA08LEDGERCODE,PA08DATEPOST,pa02subptjcode,pa02ptj code,pa02invno,pa08documentno,pa02receiptno,pa33ac countcode,pa33mainacctcode,pa33description HAVING ((PA08DATEPOST BETWEEN '"+tarikhawal+"' AND '"+tarikhakhir+"') OR (pa08datepost='"+tarikhhariini+"') OR (pa08datepost LIKE '__/"+bulan+"/2005') or (pa08datepost LIKE '______"+tahun+"')) and pa02ptjcode='"+ptj+"' and ((pa08documentno=pa02invno) or (pa08documentno=pa02receiptno)) and substr(pa08ledgercode,1,4)=pa33mainacctcode and pa02subptjcode=pa33accountcode


masalahnye skarang,saya tak tau kenape resultnye tak sum kredit dan debit tu mengikut ledgercode......masalah group by or something else?....

hope someone can help....
__________________
aku seadanya...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 27-10-2005, 11:21 PM
AbgCooL's Avatar
Senior Webmaster
 
Join Date: Jun 2002
Location: In a house...
Posts: 208
Rep Power: 83
AbgCooL is on a distinguished road
Eden rasa la kan.. ekau cuba guna SqlTalk. Lepas tu, cuba asingkan hanya bahagian yang nak di sumkan sahaja utk dapatkan result. Setahu den, cuba cek search condition ekau tu... harap ini dapat membantu.

hint: setahu den la group by tu untuk groupkan result yang akan dikeluarkan, tidak ada ape-ape kaitan dengan sum. Yang berkaitan dengan sum adalah search condition kepada maklumat tersebut.

cth: (ini dalam SQL syntax utk SQLBase)
select @sum(nama_column) from nama_table where column1<=10


Selamat!
__________________
<b>A</b>bg<b>C</b>ooL<br><i>Cool as you can be</i>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 28-10-2005, 08:18 AM
spicy_girl's Avatar
Novice Webmaster
 
Join Date: Jul 2003
Location: aku org malaysia...
Posts: 45
Rep Power: 0
spicy_girl is on a distinguished road
1st--->SqlTalk tu,tool nk uji sql ye??

2nd--> rase2nye,perlu wt 2 sql berlainan ke?then sql1+sql2+.....

3rd--> thanks mr.cool....

4th--> tgh fenin....
__________________
aku seadanya...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 22-12-2005, 04:28 PM
New kid on the block
 
Join Date: Aug 2001
Location: KL
Posts: 8
Rep Power: 0
arejae is on a distinguished road
Quote:
Originally Posted by spicy_girl
1st--->SqlTalk tu,tool nk uji sql ye??

2nd--> rase2nye,perlu wt 2 sql berlainan ke?then sql1+sql2+.....

3rd--> thanks mr.cool....

4th--> tgh fenin....
ermm...ok.first you kena troubleshoot kat mana you punya silap.

1. ok setakat yg i nampak,sql yg u tunjuk nie daripada you punya program kan sebab boleh nampak ada variable bulan,tahun,tarikhawal..etc
so,you try print out dulu sql after dah dapat semua variable tuh.tengok mana-2 ada variable yg takder nilai ker.

2. you punya sql statement nampak cam kompleks sangat.I rasa ada something wrong.You ada 3 tables
1. PA08LEDGER,
2. PA02ITEMBILL,
3. PA33ACCTCHARTDETAIL
Code:
SELECT DISTINCT PA08DOCUMENTNO,PA08DATEPOST,PA08LEDGERCODE,PA33DES CRIPTION,
SUM(PA08DTAMOUNT)AS TOTALDEBIT,
SUM(PA08KTAMOUNT)AS TOTALKREDIT 
FROM PA08LEDGER,PA02ITEMBILL,PA33ACCTCHARTDETAIL 
GROUP BY PA08LEDGERCODE,PA08DATEPOST,pa02subptjcode,pa02ptj code,pa02invno,pa08documentno,pa02receiptno,pa33ac countcode,pa33mainacctcode,pa33description having bla bla
you tak join pun antara 3 tables tuh. cth
table1.id = table2.id

maybe sepatutnya u try construct u punya sql lebih kurang camnie
Code:
select distinct f1,f2,sum(f3),sum(f4) from table1,table2,table3
where table1.id=table2.id AND table1.id=table3.id and
f1 between 1 and 2
group by f1,f2
having sum(f3) > 0
tuh cth aaa...eheh..tryloo...fenin gak tengok u nyer statement.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 27-12-2005, 08:17 AM
spicy_girl's Avatar
Novice Webmaster
 
Join Date: Jul 2003
Location: aku org malaysia...
Posts: 45
Rep Power: 0
spicy_girl is on a distinguished road
thanks arejae n abg cool....

ari tu,disebabkan dateline dh dekat sgt2 utk present module ni,so i decide utk buat satu table so that i tak perlu guna SQL yg sgt2 panjang utk view data...

so,skarang,SQL i lebih ringkas n my sum kat bhg debit and credit dh tepat....searching data pun makin cepat sbb dh pecahkan method2 untuk panggil SQL2 yang ada....

thanks guys...
__________________
aku seadanya...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
question about 2Co masrule E-Commerce 2 22-12-2007 04:08 PM
A big question for pros over here kahsoon Revenue and Monetization 3 27-01-2006 04:06 AM
session question hafizuddin Website Programming 3 13-05-2004 01:12 AM
Date question ngaisteve1 Website Programming 0 11-04-2004 09:07 PM
javascript question kelly001 Website Design 0 22-07-2003 01:20 AM


All times are GMT +8. The time now is 12:28 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61