General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 19th, 2005, 10:46 AM
Breed372 Breed372 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 7 Breed372 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 58 sec
Reputation Power: 0
Like a pivot table

I am new to SQL so please bare with me. I am trying to create collumns from rows of data. Is this possible in SQL and how do i go about doing it. What i am looking for is basically the same functionality as a pivot table in Excell or Access. Currently I am extracting the same data and creating Pivot tables with the data repetitively. Writing this in SQL would speed things Dramatically.

Reply With Quote
  #2  
Old July 19th, 2005, 11:24 AM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 6
Can you give a specific example of data you'll be working with and the data you want out of it?
__________________
"A pawn is the most important piece on the chessboard -- to a pawn"


Reply With Quote
  #3  
Old July 19th, 2005, 02:45 PM
Breed372 Breed372 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 7 Breed372 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 58 sec
Reputation Power: 0
table_one
Part Number Serial Number SITE Qty
A123 xyz 1USHB-S 1
A123 qrs 1USHB-U 1
A123 pno 1USBR-U 1
A123 pnq 1USBR-U 1

new_table
Part Number 1USHB-U 1USHB-S 1USBR-U
A123 1 1 2

Reply With Quote
  #4  
Old July 19th, 2005, 03:18 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 6
Give this a shot:

Code:
SELECT
 Part_Number
,SUM(CASE Serial_Number
         WHEN '1USHB-S' THEN SITE_Qty
        END) AS 1USHB-S
,SUM(CASE Serial_Number
         WHEN '1USHB-U' THEN SITE_Qty
        END) AS 1USHB-U
,SUM(CASE Serial_Number
         WHEN '1USBR-U' THEN SITE_Qty
        END) AS 1USBR-U
FROM
 table_one
GROUP BY
 Part_Number


If 1SDBR-U is just the end of a longer serial number (which it appears, but the spacing makes it hard to tell for sure), you'll need to extract it with SUBSTRING when you run it through the CASE statement.

Reply With Quote
  #5  
Old June 13th, 2007, 09:14 AM
dd888 dd888 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 1 dd888 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 54 sec
Reputation Power: 0
Suggestion

There is a software package I use for something similar. I think it can handle exactly what you need.

It's better because it can import and refresh from a SQL query and show the results immediately in a pivot table. It has different views on the datasource, and charting. So if you change the pivot table fields, the charts will update immediately. You also have the option of saving it in their own file format and sending the document to other people.

I know this is an old post, but I would suggest you give it a shot..

Well it blocked me from using the direct URL. The software is called numberGo. You'll be able to find it in Google. Maybe a moderator can put in the URL for me.

Good luck!
Dan

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Like a pivot table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek