DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links