Wednesday, March 7, 2012
complex report
age sex
39 M
48 F
14 M
etc...
need to be displayed as
Age Group Number of Male Number of Female Total in Age Group
0 -2 2 3
5
3 - 9 24 33
57
....
70 and above 12 11
23
Total Males ##
Total Females ##
Total
##
Any suggestions would be helpful.This question is better geared towards a SQL forum rather then reporting
services.
Search online for the SQL syntax of Case. You'll want to create a select
statment where you do something similar to this.
SELECT '0-2' as Age Group, SUM(CASE age>0 AND age < 2 AND sex = "M", 1, 0
END) as Number of Male, SUM(CASE age>0 AND age < 2 AND sex = "F", 1, 0 END)
as Number of Female, SUM(CASE age > 0 AND age < 2) as Total in Age Group
UNION
SELECT '3-9' as Age Group, SUM(CASE age>3 AND age < 9 AND sex = "M", 1, 0
END) as Number of Male, SUM(CASE age>3 AND age < 9 AND sex = "F", 1, 0 END)
as Number of Female, SUM(CASE age > 3 AND age < 9) as Total in Age Group
And so on and so forth for each of the age/sex ranges.
-Michael Abair
Programmer Analyst
Chicos FAS Inc
"Chop" <Chop@.discussions.microsoft.com> wrote in message
news:0D4FB1BC-D77D-4E6B-A728-B798B6EAF6E4@.microsoft.com...
> have the following data from a query
> age sex
> 39 M
> 48 F
> 14 M
> etc...
> need to be displayed as
> Age Group Number of Male Number of Female Total in Age Group
> 0 -2 2 3
> 5
> 3 - 9 24 33
> 57
> ....
> 70 and above 12 11
> 23
> Total Males ##
> Total Females ##
> Total
> ##
> Any suggestions would be helpful.|||You also have the option of creating fields within RS; for the values
use:
iif(fields!age.value >=0 and fields!age.value < 3, "0 - 2",
iif(fields!age.value < 10, "3-9", ...))
Then use a matrix item and use the calculated field as your row group,
sex as your column group.
Chop wrote:
> have the following data from a query
> age sex
> 39 M
> 48 F
> 14 M
> etc...
> need to be displayed as
> Age Group Number of Male Number of Female Total in Age Group
> 0 -2 2 3
> 5
> 3 - 9 24 33
> 57
> ....
> 70 and above 12 11
> 23
> Total Males ##
> Total Females ##
> Total
> ##
> Any suggestions would be helpful.
Complex query, whats the best way?
I have a query that must return information for an invoice. It is not straight forward though. Some things need to be displayed from the if something else is happening...
For example...
declare @.idintdeclare @.chargeidintset @.id = 1set @.chargeid = 9declare @.ppbit, @.pagesint, @.pagefeemoney, @.pagechargemoneyset @.pp = (select perpagefrom tblmainfeeswhere mainfeesid = @.chargeid)if (@.pp = 1)beginset @.pages = (select pagesfrom tblchargesinnerjoin tblrequeston requestid = fkrequestidwhere requestid = @.id)if (@.pages > 0)beginset @.pagefee = (select perpagefeefrom tblmainfeeswhere mainfeesid = @.chargeid)set @.pagecharge = (@.pages * @.pagefee)endend...select @.pagechargeas PerPageCharge
Or should I do some complex query with only one select?
Its hard for anyone to understand if your question is like this: "Some things need to be displayed from the if something else is happening..."
Give us some sample data and your query and what you are expecting to see out of it.
|||Your right, sorry about that. I slid that one in quick before a meeting...
I will try to explain better.
I have stored procedure that returns data for an invoice, and because Ihate Crystal Reports, I do the most work I can in the stored procedure (formating the text, etc...).
The current query I have involves a 2 complex queries with tons of nested case statements. It is hard to read and does not flow nicely at all, but it works.
I just made enough changes to the database that the stored procedure needs to be rewritten.
I took this opportunity to try and clean up what I wrote prior. I posted a small expample above.
To me, I made it almost "VB" like. Instead of complex select statements with nested logic, I made a variable for each item I needed, and some extra variables for logic. I set each of these variables with it's own select statement, if they passed the logic i had layed out (most of them were initialized with a value). Again, to me, I envisioned each variable being set like a property or a function in VB. I ended up having over 15 simple selects to set variables, and one select at the end to return (get) all of the variables.
The code ended up being much easier to read, and I cut the original code in half, but I greatly increased the amount of select statements. I did some time statistics to see which was faster, and the new query ended up being twice as fast, doing the same work.
My question: Is the way I described and used an accepted way practice? Did I make it some what clearer of what I did or am trying to do?
|||I would post some data and examples, but I don't think it's relevant. I am not looking for how to do something, but the best way to do something.
For example: "Are you stupid? Don't do it like that." or "Yeah, that's fine.
"
Friday, February 17, 2012
compilation error while adding web reference RS05
if i try to add a web reference in my c# application to reporting services
2005 i got a compilation error.
a part of the displayed message:
--
source error:
line 4: <%@. Import Namespace="System.Xml" %> <-- is a red line
error message:
CS0234: The type or namespace name 'Xml' does not exist in the namspace
'System' (are you missing an assembly reference?
do anybody know a solution for this problem?
thx
MartinTake a look at this forum:
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=10847
particularly the post from AkhilaL MSFT
Jens Konerow