Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2017
    Posts
    1

    Unanswered: Need help in mysql query

    Hi All,

    i have a table in mysql with the following data

    Code:
    Table name Test
    
    Assettype   Serial_No     Status               location    
    Mouse        123456	  In Stock            chennai
    Mouse        98765 	  Allocated           chennai
    Keyboard    23498          In Stock            bangalore
    Keyboard    45646	  Allocated           bangalore

    i am looking for a mysql query which will give the below mentioned output

    Code:
          
    Assettype    In Stock Allocated  Location  
    Mouse             1            1         chennai          
    Keyboard         1             1         bangalore

    Kindly help
    Last edited by gosatriani; 01-07-17 at 02:46. Reason: alignment

  2. #2
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    530
    Code:
    select Assettype, count(*) 'In Stock', 1 'Allocated', location
    from Test
    where Status = 'In Stock'
    group by Assettype, location
    I don't understand the significance of "Allocated"
    F. Celaia
    DBA Oracle/MS-SQL/MySQLSybase/DB2/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •