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:
Laplink Gold 2008 - $15 Off with Coupon Code CJM9NE
  #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: 4
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: 4
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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway