i have database design this...
dated ref weight no. address 21-03-2013 abcd/edfg 1234 a45 a1 20-03-2013 abcd/edfg 789 a56 a2 25-03-2013 abcd/edfg 6981 a99 a5 23-03-2013 gajhs/asdh 72 a82 gv
what want here in query result this....
search on basis of no.
then, has see if ref of row exists more times , if exists has add weight of such rows keeping in mind dated of such records should less dated of selected no..
example -
no. = a56 3 rows exist same ref(abcd/edfg) dated of a56 lower among results should ref ------ weight -------- no. -------- address abcd/edfg ------ 789 ----------- a56 -------- a2
but in case of no. = a99 results should -
ref ----------- weight -------- no. -------- address abcd/edfg --- (789+6981+1234) ----------- a99 -------- a5 dated of a99 greater other 2 records.
please me in query.
select ref, sum(weight) on (partition ref order dated) weight, no, address ...
Comments
Post a Comment