| Author |
Topic |
|
hacke_02
Starting Member
8 Posts |
Posted - 2009-05-25 : 12:02:12
|
table A------------------------------------------ID | Name | email | S_ID |------------------------------------------D-01 | XXXX | XXXXXXXXX | S-01 |D-02 | XXXX | XXXXXXXXX | S-02 |D-03 | XXXX | XXXXXXXXX | S-03 |D-04 | XXXX | XXXXXXXXX | S-03 |D-05 | XXXX | XXXXXXXXX | S-04 |D-06 | XXXX | XXXXXXXXX | S-05 |D-07 | XXXX | XXXXXXXXX | S-05 |-------------------------------------------table B------------------------------S-ID | status | salary |------------------------------D-01 | XXXX | 6000 |D-02 | XXXX | 4000 |D-03 | XXXX | 3500 |D-04 | XXXX | 2500 |D-05 | XXXX | 1500 |table C------------------------------ID | date | overtimehour |------------------------------D-02 | 24-oct | 3 | D-03 | 26-oct | 4 |D-03 | 23-oct | 3 |D-04 | 25-oct | 5 |D-04 | 24-oct | 4 |D-05 | 20-oct | 3 |D-05 | 24-oct | 9 |D-05 | 28-oct | 10 |---------------------------Question Is:display A.name, A.email, B.status ,B.sallarynote:ID which has overtime must be overpayand 1 hour multiplied 3%Example:ID = D-04 have double overtime,which has a 9 hour in table Cso his overtime wages is 9 * 3 * 2500 / 100and his sallary in oct month ic2500 + 675 some one HELP ME PLEASE, It's So Important, it's the task of school by jj |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-05-25 : 12:08:36
|
| What have you tried so far?==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
hacke_02
Starting Member
8 Posts |
Posted - 2009-05-25 : 12:15:20
|
i has try with join tableand another solve, but which ID= D-01 Always NULLcant your show the code ???? by jj |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2009-05-25 : 12:30:06
|
quote: Originally posted by hacke_02
some one HELP ME PLEASE, It's So Important, it's the task of school
So you want us to do your homework for you?Show us what you're done, explain what you're struggling with and show that you've made some effort and someone will probably help you.If we just give you the answer, then you've learnt nothing.--Gail ShawSQL Server MVP |
 |
|
|
hacke_02
Starting Member
8 Posts |
Posted - 2009-05-25 : 12:40:01
|
| sorry for a cross posting...I have to try it, books, e-book, website, to my despair.therefore, I try to ask in this forum.i know thats logicbut the view that I can always null in D-01.because the salaries in D-01 multiplied by the null or something that does not exist.how to avoid this problemthank'sby jj |
 |
|
|
hacke_02
Starting Member
8 Posts |
Posted - 2009-05-25 : 13:08:52
|
| select A.ID,A.Email,B.status,B.sallary + sum(C.overtime)*0.03*B.sallryfrom A left outer join B on A.s-id = b.s-idinner join C on C.ID = A.IDgroup by A.ID,A.Email,B.statusby jj |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2009-05-25 : 15:27:42
|
| Ok, and what's the problem you're having? What doesn't that query do that it should?If it's nulls that are the problem, lookup ISNULL in the SQL books online. Oh, and you're missing a column from your group by clause. Any columns in the select that are not aggregated must be in the group by clause.--Gail ShawSQL Server MVP |
 |
|
|
hacke_02
Starting Member
8 Posts |
Posted - 2009-05-26 : 02:38:56
|
| thank's, i'll try it first.if i met anymore problems, i'll ask u guys again.Thanks a lot for helping me outby jj |
 |
|
|
hacke_02
Starting Member
8 Posts |
Posted - 2009-05-28 : 03:16:47
|
| I had try wiht the code, and it's work..SELECT karyawan.nokar,karyawan.namakar,jabatan.namajab,jabatan.gaji + sum(isnull(lembur.jml_jam,'0')* 0.03 * gaji )as 'total'FROM karyawan left outer join lembur on karyawan.nokar = lembur.nokar INNER join jabatan on karyawan.nojab = jabatan.nojabGROUP BY karyawan.nokar,karyawan.namakar,jabatan.namajab,jabatan.gajiand i want to ask some thing..how to remove zore behind koma (exp; 100.00)and have any syntax from what i done??to slove that case??? thank's a lote by jj |
 |
|
|
prav3575
Starting Member
5 Posts |
Posted - 2009-05-28 : 04:28:07
|
| you can also try with one of inline queryselect a.name,a.email,b.status,(select isnull(sum(overtime)* 3* b.salary/100,0)+ b.salary total_sal from table_c where id=a.id) totfrom table_a a inner join table_b bon a.id=b.s_id |
 |
|
|
prav3575
Starting Member
5 Posts |
Posted - 2009-05-28 : 04:43:01
|
| this query is using joins select a.name,a.email,b.status,isnull(sum(c.overtime)* 3* b.salary/100,0)+ b.salaryfrom table_a a left outer join table_c c on a.id=c.idinner join table_b b on a.id=b.s_idgroup by a.name,a.email,b.status,b.salary |
 |
|
|
hacke_02
Starting Member
8 Posts |
Posted - 2009-05-28 : 06:50:06
|
hiuhh,, i think i must learn more..but thank for all by jj |
 |
|
|
|