Another solution using unions and is more portable:
Code:select branch, sum(basic_pay) as regular, sum(0) as contractual from salary where emp_status='regular' group by 1 union all select branch, sum(0) as regular, sum(basic_pay) as contractual from salary where emp_status='contractual' group by 1
You're welcome!![]()
naa nasad ko i-inquire ninyo sir:
customerNo | Lname | Fname| mInitial | address
00001 | Ang | Vic | T | Cebu City
00002 | Ballesteros | Tom | R | Talisay City
00003 | Pino | Bing | C | Cebu City
00004 | Sanchez | Lyn | V | Mandaue City
00005 | Uy | Amy | A | Cebu City
ang pangutana nako ani sir, if mag-query gani ko nga update murag ingon ani ba:
if ni exist na ang iyang customerNo iya ra i-update ang tanang fields and if wala pa
ni-exist kay iyang i-insert ang bag-o nga entry...
situation1: naay bag-o nga entry nya naa lets say 00003, Rama, Bing, P , Davao City kani kay
naa na man ang iyang customerNo iya ra i-update ang mga fields...
situation2: 00010, Mersiditas, Melinda, C, Cebu City kani kay bag-o man ang iyang CustomrNo
i-insert ni tanan
thnx daan sir...
^^^ wow nice ni nga command dah...very handy...naa ni xa nga command sa postgres bro?
Check this out lang bro,
Programming:Converting MySQL to PostgreSQL - Wikibooks, collection of open-content textbooks
wala kaayo ko kakuha sa REPLACE sir,
ani man gud na siya, java nga code nya galoop ni siya bali
ang query ani niya condition gani nga if customerNo ni exists update lang if wala so insert:
ang syntax unta ani nga flow akong gi-mean ani sir, sa MySQL
Similar Threads |
|