Showing posts with label region. Show all posts
Showing posts with label region. Show all posts

Wednesday, March 28, 2012

Grouping Problem

I have a table that contains a region, year, part, and quantity. I want the
query output to be one line per region with the years as columns for the sum
of the quantities. I've tried this, but I get one line per year instead of
one line per region.
SELECT
PART_ID,
REGION,
CASE Report_Year WHEN '2000' THEN SUM(Total_Inbound) ELSE 0 END AS "2000",
CASE Report_Year WHEN '2001' THEN SUM(Total_Inbound) ELSE 0 END AS "2001",
CASE Report_Year WHEN '2002' THEN SUM(Total_Inbound) ELSE 0 END AS "2002",
CASE Report_Year WHEN '2003' THEN SUM(Total_Inbound) ELSE 0 END AS "2003",
CASE Report_Year WHEN '2004' THEN SUM(Total_Inbound) ELSE 0 END AS "2004",
CASE Report_Year WHEN '2005' THEN SUM(Total_Inbound) ELSE 0 END AS "2005",
CASE Report_Year WHEN '2006' THEN SUM(Total_Inbound) ELSE 0 END AS "2006",
SUM(Total_Inbound) AS TOTAL_QTY
FROM dbo.tblGlobalInboundVolumes
GROUP BY PART_ID, Region, Report_Year
HAVING (PART_ID = 'KRC12110/3 R11F')Never mind...I figured it out
"Phill" wrote:

> I have a table that contains a region, year, part, and quantity. I want t
he
> query output to be one line per region with the years as columns for the s
um
> of the quantities. I've tried this, but I get one line per year instead o
f
> one line per region.
> SELECT
> PART_ID,
> REGION,
> CASE Report_Year WHEN '2000' THEN SUM(Total_Inbound) ELSE 0 END AS "2000",
> CASE Report_Year WHEN '2001' THEN SUM(Total_Inbound) ELSE 0 END AS "2001",
> CASE Report_Year WHEN '2002' THEN SUM(Total_Inbound) ELSE 0 END AS "2002",
> CASE Report_Year WHEN '2003' THEN SUM(Total_Inbound) ELSE 0 END AS "2003",
> CASE Report_Year WHEN '2004' THEN SUM(Total_Inbound) ELSE 0 END AS "2004",
> CASE Report_Year WHEN '2005' THEN SUM(Total_Inbound) ELSE 0 END AS "2005",
> CASE Report_Year WHEN '2006' THEN SUM(Total_Inbound) ELSE 0 END AS "2006",
> SUM(Total_Inbound) AS TOTAL_QTY
> FROM dbo.tblGlobalInboundVolumes
> GROUP BY PART_ID, Region, Report_Year
> HAVING (PART_ID = 'KRC12110/3 R11F')|||Try:
SELECT
REGION,
CASE Report_Year WHEN '2000' THEN SUM(Total_Inbound) ELSE 0 END AS "2000",
CASE Report_Year WHEN '2001' THEN SUM(Total_Inbound) ELSE 0 END AS "2001",
CASE Report_Year WHEN '2002' THEN SUM(Total_Inbound) ELSE 0 END AS "2002",
CASE Report_Year WHEN '2003' THEN SUM(Total_Inbound) ELSE 0 END AS "2003",
CASE Report_Year WHEN '2004' THEN SUM(Total_Inbound) ELSE 0 END AS "2004",
CASE Report_Year WHEN '2005' THEN SUM(Total_Inbound) ELSE 0 END AS "2005",
CASE Report_Year WHEN '2006' THEN SUM(Total_Inbound) ELSE 0 END AS "2006",
SUM(Total_Inbound) AS TOTAL_QTY
FROM dbo.tblGlobalInboundVolumes
WHERE (PART_ID = 'KRC12110/3 R11F')
GROUP BY Region
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
"Phill" <Phill@.discussions.microsoft.com> wrote in message
news:457D9064-2B3B-4243-8648-E5884B22102E@.microsoft.com...
I have a table that contains a region, year, part, and quantity. I want the
query output to be one line per region with the years as columns for the sum
of the quantities. I've tried this, but I get one line per year instead of
one line per region.
SELECT
PART_ID,
REGION,
CASE Report_Year WHEN '2000' THEN SUM(Total_Inbound) ELSE 0 END AS "2000",
CASE Report_Year WHEN '2001' THEN SUM(Total_Inbound) ELSE 0 END AS "2001",
CASE Report_Year WHEN '2002' THEN SUM(Total_Inbound) ELSE 0 END AS "2002",
CASE Report_Year WHEN '2003' THEN SUM(Total_Inbound) ELSE 0 END AS "2003",
CASE Report_Year WHEN '2004' THEN SUM(Total_Inbound) ELSE 0 END AS "2004",
CASE Report_Year WHEN '2005' THEN SUM(Total_Inbound) ELSE 0 END AS "2005",
CASE Report_Year WHEN '2006' THEN SUM(Total_Inbound) ELSE 0 END AS "2006",
SUM(Total_Inbound) AS TOTAL_QTY
FROM dbo.tblGlobalInboundVolumes
GROUP BY PART_ID, Region, Report_Year
HAVING (PART_ID = 'KRC12110/3 R11F')

Monday, March 26, 2012

Grouping Data in Matrix like Table control

All,

Is it possible to Group data in a Matrix exactly similar to Table Control. For example, my table control would group data as follows:

Region Country City $ales

North America

USA

Chicago 4 MM

LA 10 MM

NYK 6 MM

Canada

Toronto 4 MM

while the matrix would display as:

North America USA Chicago 4MM

LA

NYK

Canada Toronto ...

Do you see the problem? The matrix is starting the subgroup at the same level as the parent group. How do I make a sub group start at the row below the parent group row in matrix just like in the table above?

Any one?

On a related note, How can I add the "heading" to the dynamic rows in the matrix similar to table:

Region Country City Sales

North America 10 MM

USA 8 MM

Chicago 2 MM

LA 2 MM

NYK 4 MM

Canada 2 MM

Toronto 2 MM

Can a matrix be formatted as above, it can be in a table but I am not sure if this can be achieved with Matrix?

|||This issue is now resolved. The SubTotal property of each Row/Column grouping in a Matrix could be set to "Before/After" the details cells to achieve the desired format. Matrix is an amazing tool created by the SSRS team but it does require you to fiddle with it a bit before being used effectively. It saved me from having to write a Cross Tab query in dynamic SQL.|||

Were you able to get the headings on the columns? That's what I've been fighting with, but I haven't been able to figure it out.

Thanks,

Marianne

|||

DotNet_Guy wrote:

Matrix is an amazing tool created by the SSRS team but it does require you to fiddle with it a bit before being used effectively.

SSRS 2008 will include a Tablix (cross between a table and a matrix) due to grouping issues and the like that couldn't previously be accomplished easily.

Friday, March 23, 2012

Grouping

I keep recieving an error: "The table 'table1' is in a list that has no group expressions defined for it. To use a data region in a list, the list must have group expressions." I have a list that contains a table, and would like the table to change with each item of the list. I looked at the grouping, but I didn't know what to do, and didn't see any tutorials out there for ReportViewer.Be sure that you are looking at the grouping for the list, not for the table. List Properties -> Edit Details Group...|||

Many Thanks, your First Post is very Helpfull

Thankswildbill0283

sql

Wednesday, March 21, 2012

group rpt hdgs not appearing on all pgs

Hello,

Both my table and group headings in my table data region are not appearing on all pages of my report however I have the "repeat group header on all pages" option selected at the group level as well as at the table level. Any suggestions?

Which renderer are you using? If it's HTML, these headers should appear on each page where the table/group is on. If it's PDF or Image, there might be cases where we have to drop these headers in order to fit the table or group contents since we are bound by the physical page size.|||I'm running the report thru Visual Studio's report manager interface. I tried saving the report as a .pdf file and it saved it just as I viewed on the screen.