Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1

    Default HELP: in MySQL query


    Mga boss, unsa-on mani siya pag-query:

    "select sum(basic_pay) as regular from salary where emp_status='regular'"
    "select sum(basic_pay) as contractual from salary where emp_status='contractual'"

    kung usahon lang ni siya pag-query bah...help needed gyud kaayo mga ka-istoryans nga mga maayo ug sql...

    thnx

  2. #2
    same column sila?
    Union gamita >_>

  3. #3
    The 2 sql statements are valid.

    If want 2 records resuls with for each emp_status you could use:
    select emp_status, sum(basic_pay) as basic_pay_sum from salary group by 1

    I suggest to give more details on your problem/question. One could not guess what you really need.

  4. #4
    bali ingon ani na ug porma sa database:
    branch |employee | salary | emp_status
    -------------------------------------------------------------
    Cebu |Sanchez, A. | 10000.00 | regular
    Davao |Yan, B. | 8000.00 | contractual
    Cebu |Uy, C. | 7000.00 | regular
    Manila |Martin B. | 6000.00 | contractual

    =====================================
    nya ang gusto unta nako, nga ang output ingon ani:
    branch |regular | contractual
    ---------------------------------------
    Cebu |17000 |
    Davao |8000 |
    Manila | | 6000

    tabang pod mga ka-istoryans kay bag-o paman gud ko ani sql gud...thnx daan

    sori, ana diay ni iya output
    Last edited by rastaman81; 01-18-2009 at 11:44 PM. Reason: wrong information

  5. #5
    unsa-on mani ug paagi

    tabang sad mo diha katong makamao ug mysql...

    thnx

  6. #6
    ngano ang output kay ang davao naay 8000 regular ug 8000 contractual, sa database sample 8000 contractual ra man sa davao?

  7. #7
    "select sum(basic_pay) as regular from salary where emp_status='regular'"
    "Union"
    "select sum(basic_pay) as contractual from salary where emp_status='contractual'"

    >_>

  8. #8
    Quote Originally Posted by Cruzader View Post
    "select sum(basic_pay) as regular from salary where emp_status='regular'"
    "Union"
    "select sum(basic_pay) as contractual from salary where emp_status='contractual'"

    >_>
    naka try nako ani brod pero ang out put gud ani kay walay label ang naa sa ubos nga union dili siya madistinguish ug contractual ba gyud. kay ang label sa babaw regular man...

  9. #9
    ^ La man pud labels ni
    Cebu |17000 |
    Davao |8000 |
    Manila | | 6000

    Unsao gud ng klarong output

  10. #10
    with mysql, you could do this:
    Code:
    select branch, 
    	sum(if(emp_status='regular',basic_pay,0)) as regular,
    	sum(if(emp_status='contrctual',basic_pay,0)) as contractual
    	from salary
    	group by 1
    Last edited by cold_fusion; 01-19-2009 at 09:41 AM.

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. MySQL Query Help : Foreign Keys
    By cjoyce12 in forum Programming
    Replies: 0
    Last Post: 01-06-2011, 06:57 PM
  2. i need ur help in query sa vb
    By skeptic_rob in forum Programming
    Replies: 15
    Last Post: 12-31-2010, 10:38 PM
  3. mysql help in outfile query
    By kurokotoque in forum Programming
    Replies: 1
    Last Post: 03-13-2009, 12:48 AM
  4. Need help MYSQL Query on dynamic table..
    By salbahis in forum Programming
    Replies: 6
    Last Post: 11-15-2008, 11:25 AM
  5. HELP! Conditional Statements in MYSQL
    By tynum in forum Programming
    Replies: 17
    Last Post: 10-06-2008, 04:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top