SQL Prob in displying


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: SQL Prob in displying

  1. #1
    Arun Guest

    SQL Prob in displying


    Hi all

    I have Table Like This

    PartNo Type Qty
    100 1 100
    100 2 200
    100 3 100
    101 1 60
    100 4 199
    101 2 298
    ... . ...
    ... . ... so on

    Is there any SQL Statement so i can display my data as follow

    PartNo 1 2 3 4 ......
    100 100 200 100 199 so on if any
    101 60 298 0 0
    ... ... ... ... ....
    ... ... ... ... . ..

    i think we gave in Oracle , i do'nt know much in MS-SQL 2000

    Thanks











  2. #2
    Madhusdana Naidu Guest

    Re: SQL Prob in displying


    U can get your desired results by using CASE function

    SELECT PARTNO, SUM(CASE TYPE WHEN 1 THEN QTY ELSE 0 END) AS TYPE1,
    SUM(CASE TYPE WHEN 2 THEN QTY ELSE 0 END) AS TYPE2,
    SUM(CASE TYPE WHEN 3 THEN QTY ELSE 0 END) AS TYPE3,
    SUM(CASE TYPE WHEN 4 THEN QTY ELSE 0 END) AS TYPE4
    FROM CASEUSE GROUP BY PARTNO

    Madhu.

    "Arun" <arunhalyal@verisecnet.com> wrote:
    >
    >Hi all
    >
    >I have Table Like This
    >
    >PartNo Type Qty
    >100 1 100
    >100 2 200
    >100 3 100
    >101 1 60
    >100 4 199
    >101 2 298
    >... . ...
    >... . ... so on
    >
    >Is there any SQL Statement so i can display my data as follow
    >
    >PartNo 1 2 3 4 ......
    >100 100 200 100 199 so on if any
    >101 60 298 0 0
    >... ... ... ... ....
    >... ... ... ... . ..
    >
    >i think we gave in Oracle , i do'nt know much in MS-SQL 2000
    >
    >Thanks
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center