Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pivot value from a table

Posted on 2013-07-01
1
Medium Priority
?
291 Views
Last Modified: 2013-07-07
Hi Experts,

I have attached an excel file. The top resultset is the way the
result gets displayed before the pivot. The second is
after the pivot is applied. I have a wuery currently that gives me
the second resultset after the pivot.

Below is the current query.



Here's what I want to do. I would want to get these values
from a table as there is a table that contains the values in [5],[-5],[1],[-1] that
I have hardcoded in pivot. I have commented out a field in the query as
Select *from tbl1. So here's basically what I am looking at

PIVOT
(
sum(maintab.amt)  
FOR maintab.scendes in (Select *from tbl1).

Not sure if it is possible or not but your help will be highly
appreciated.
pid.xls
0
Comment
Question by:Josh2442
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 1220 total points
ID: 39291876
Hi. The value list in the PIVOT operator has to be static, so you will need to use dynamic sql to get list from a query. An alternative is to PIVOT in a client reporting tool, such as Excel.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question