I might be looking at this from the completely wrong angle, making this way harder than it needs to be, so maybe some fresh perspectives will help.
Let's say I have a simple SELECT that returns the total number of Orders for a given date, grouped by Order Status and Order Date. So my columns returned are as follows:
Date - Status - NumOrders
Now, what I want to do is create another very simple table that has essentially 3 columns:
Date - ShippedOrders - TotalOrders
07/02 23 100
Now the Shipped Orders column is simply just one of the many status' that I have in my recordset, i.e.
07/02/2007 - Shipped - 23
My first thought would be to simply filter on my Shipped Orders column, however, it appears that SSRS only supports filters at the data region level, which wouldn't help my situation.
It feels like I'm missing something very basic here, so perhaps my brain is a bit cloudy from the weekend. I know I can achieve what I'm looking to do by easily manipulating the SQL, but I'm trying to increase my comfort level with SSRS. Any insight is appreciated.
I have what at first site should be a simple reporting services issue but cannot resolve:-
I have a complex report comprising over 90 pages of various sections but when analysed in detail , 80% of it follows a simple pattern i.e. it comprises around 100 instances of the same sub-report bound to the same data source BUT grouped and filtered on different groupings and filter values.
The pattern is as follows:-
Each sub-report instance is bound to an SSAS cube which has fields L1, L2...L7
Each sub-report instance groups the data dynamically by one or more groups G1,G2..G7, the actual fields to be used being defined by the parent report (i.e. one instance may group by fields L7, L3, L4, another by L2,L3 etc)
Each sub-report instance has up to 7 filters defined (F1..F7) may filter the data i.e. the parent may pass a filter stipulating that L7="A", L3="B". To do this, the parent sets filter parameters F7="A" and F3="B"
The approach I have adopted is to set up parameters in the sub-report for dynamically grouping the data i.e. the sub-report has 7 parameters defined G1..G7 and the parent report populates G1..G7 with the grouping breakdown required for any given instance. This works fine!!!!
However what I am trying to do is prevent each sub-report performing major round trips to the underlying cube for each sub-report instance by specifying the filter as part of the MDX query by defining the 7 filter parameters as query parameters. (I could of course not filter the query and place the filter in the report but this would almost certainly lead to performance issues). Instead what I am struggling to do is to create the MDX query in such a way that when a filter is not supplied by the parent, the MDX query does not filter the data.
Can anyone advise on this. I guess my question is more of an MDX question than a reporting services one.
There's some SQL below (T-SQL) & I'm wanting to have this result set grouped by Venue_ID in order to remove rows where there are duplicate values contained in just one column.
The columns BCOM_ID contain unique values, but Venue_ID can have duplicate values. I only want to get rows for one instance of the Venue_ID (per BCOM_ID) - doesn't matter which instance but basically, no duplicates.
Oh yes, one of the columns is a Bit column.
Any ideas would be welcome & appreciated!
Many thanks, Darren darren@darrenbrook.fsnet.co.uk
SQL:-
SELECT Booking_Header.BH_ID, Booking_Header.Booking_Header_Description, Booking_Header.BStat_ID, Booking_Header.BT_ID, Booking_Header.Tagged, Booking_Header.Status_Timestamp, Booking_Header.Start_Date, Booking_Header.Days_Qty, Proposal.PPL_ID, Proposal.PPL_Status, Booking_Component.BCOM_ID, Booking_Component.Component_Description, Booking_Component.Venue_ID, Venue.Venue_Code, Venue.Description, Address.Address_ID, Address.Town, Booking_Status.BStat_Description, Booking_Type.Type_Description FROM dbo.Booking_Header INNER JOIN dbo.Proposal ON dbo.Booking_Header.BH_ID = dbo.Proposal.BH_ID INNER JOIN dbo.Booking_Component ON dbo.Proposal.PPL_ID = dbo.Booking_Component.PPL_ID INNER JOIN dbo.Venue ON dbo.Booking_Component.Venue_ID = dbo.Venue.VE_ID INNER JOIN dbo.Address ON dbo.Venue.VE_ID = dbo.Address.VE_ID INNER JOIN dbo.Booking_Status ON dbo.Booking_Header.BStat_ID = dbo.Booking_Status.BStat_ID INNER JOIN dbo.Booking_Type ON dbo.Booking_Header.BT_ID = dbo.Booking_Type.BT_ID WHERE (dbo.Proposal.PPL_Status = 1) AND (dbo.Booking_Header.BH_ID = 10)
I'm really stumped on this one. I'm a self taught SQL guy, so there is probobly something I'm overlooking.
I'm trying to get information like this in to a report:
WO# -WO Line # --(Details) --Work Order Line Detail #1 --Work Order Line Detail #2 --Work Order Line Detail #3 --Work Order Line Detail #etc --(Parts) --Work Order Line Parts #1 --Work Order Line Parts #2 --Work Order Line Detail #etc WO# -WO Line # --(Details) --Work Order Line Detail #1 --Work Order Line Detail #2 --Work Order Line Detail #3 --Work Order Line Detail #etc --(Parts) --Work Order Line Parts #1 --Work Order Line Parts #2 --Work Order Line Parts #etc
I'm unable to get the grouping right on this. Since the line details and line parts both are children of the line #, how do you do "parallel groups"?
There are 4 tables:
Work Order Header Work Order Line Work Order Line Details Work Order Line Requisitions
The Header has a unique PK. The Line uses the Header and a Line # as foreign keys that together are unique. The Detail and requisition tables use the header and line #'s in addition to their own line number foreign keys. My queries ends up looking like this:
It probobly isn't best practice, but I'm kinda new so I need some guidance. I'd really appreciate any help! Here's my query:
SELECT [Work Order Header].No_ AS WO_No, [Work Order Line].[Line No_] AS WOL_No, [Work Order Requisition].[Line No_] AS WOLR_No, [Work Order Line Detail].[Line No_] AS WOLD_No FROM [Work Order Header] LEFT OUTER JOIN [Work Order Line] ON [Work Order Header].No_ = [Work Order Line].[Work Order No_] LEFT OUTER JOIN [Work Order Line Detail] ON [Work Order Line].[Work Order No_] = [Work Order Line Detail].[Work Order No_] AND [Work Order Line].[Line No_] = [Work Order Line Detail].[Work Order Line No_] LEFT OUTER JOIN [Work Order Requisition] ON [Work Order Line].[Work Order No_] = [Work Order Requisition].[Work Order No_] AND [Work Order Line].[Line No_] = [Work Order Requisition].[Work Order Line No_]
I need help with filtering a specific set of numbers. I have a Sql database that is connected to my sql report I have created a tsql statement that pulls a clients name, PO, and invoice number. The prblem I am having is I have 2 different types of invoice numbers one number looks like 123456-1234-T the other looks like 123455-1234-L I need to beable to pull only the invoices with T on one report and L on another report can some on show me how I can sort these in a tsql script
This may be simple, but I can't figure a way to do this. I have the following data returned to a table and need to sum only the items where HDMethod=0 in the table footer. For some reason, something like:
=Sum(Iif(Fields!HDMethod.Value=0, Fields!BDExtended.Value, Nothing)) returns all the rows. There is a LEFT OUTER JOIN: dbo.[Billing Detail].Item = dbo.[History Detail].Item between the tables touched in the query if that helps.
a text input for filtering a gridview that displays the data an SqlDataSource that contains the query. Users can either enter something into the text input or leave it blank. Depending on that, the gridview should either display all data (unfiltered, because nothing was entered into the text field) or filtered data (when something is entered). Now my problem is in defining the query in the SqlDataSource. I could do something like this: SELECT * FROM myTable WHERE myField = @p1; and then add in the appropriate <asp:ControlParameter /> under the <SelectParameters> tag. However, this sorta "fixes" the filter. Regardless of whether users actually type something in or not, the filter is in effect. I want it in such a way that if users do not type in anything, the query essentially becomes: SELECT * FROM myTable; Is there any way to achieve this? Thanks in advance, jason
I'm not sure if this is possible and have been having trouble figuring out the code to do this. I am assigning row_number to a gridview. I then want to filter the results with a dropdown. I am able to get the filter to filter the status but it either renumbers the gridview or it leaves the row numbers blank. Is there a way to have the row_numbers stick to the gridview when I filter? Example below. Thanks Normal:IssueNumber(row_number), Status1, Open2, Open3, Closed4, Open5, Closed "Open" Filter:IssueNumber(row_number), Status1, Open2, Open4, Open "Closed" Filter:IssueNumber(row_number), Status3, Closed5, Closed
Why is Select * from [Merchandise] where [Product Name] like '[ABCD]%'the same as Select * from [Merchandise] where [Product Name] between 'A' and 'D'I can run Select * from [Merchandise] where [Product Name] like 'A%'and get Products that start with the letter "A" but they don't show up when I try to get all "A","B","C","D" Products.
I think I might be missing something here. Here is what I'd like to do:1. Retrieve a list of data from SQL Server.2. Display that data in a gridview.3. Have the user click on a button to then see a subset of that data. (filtering) I can't seem to make this work. When the user clicks the button, I need the GridView to update to show only the specified data. In 1.1 I would created a DataView for the filtering, but am trying to use the latest and greatest. I've seen examples online of people using DropDownLists to act as the dynamic filter parameter. How can I programatically assign this to make it work?Thanks!
Our current method of limiting what data a user can see is implemented solely through our Web based business intelligence tools. No filtering is enabled at the database level. This has become somewhat cumbersome as security is tied exclusively to these tools. The tools use one common logon to access the underlying database.
I would like to implement security at the database level (SQL Server 2000) and thereby produce a more flexible/portable solution. I was thinking of setting up individual database accounts for each user and then tying these into our company structure table by passing system_user result to a constraint.
For example System User name 'Store 2' would reference Store '2' in the structure table. Depending on the user, different columns will need to be referenced to filter the rows. A store user would be validated against the store column, an Area Manager user would be validated against the Area Manager column and Head Office users would not be valiadated at all i.e. they are not filtered.
1) What is the best method to implement such a look up. Can or should I use Check constraints for such a solution?
2) Would a UDF be useful?
Any ideas on the best approach to take would be greatly appereciated.
I'm new to SQL Server so if the following sounds stupid then apologies. I am trying to design a query which compares columns and filters according to the result of the comparison. We are a UK based charity that provides financial help to families with disabled children (www.familyfund.org.uk). We have a large database (250,000 entries) which we know contains some duplicate/split files from a recent migration. We need to identify these files but not delete them. Currently I am using the following:
SELECT dbo.Families.famId, dbo.Address.street, dbo.Children.childId, dbo.Address.postcode FROM dbo.Children INNER JOIN dbo.Families ON dbo.Children.family_no = dbo.Families.famId INNER JOIN dbo.Persons ON dbo.Families.famId = dbo.Persons.famId INNER JOIN dbo.Address ON dbo.Persons.addressId = dbo.Address.addressId WHERE (NOT (dbo.Children.eligStatus IN (3, 4))) GROUP BY dbo.Children.childId, dbo.Address.postcode, dbo.Families.famId, dbo.Address.street HAVING (dbo.Address.street IS NOT NULL) ORDER BY dbo.Address.street
Obviously this returns all 250,000 records and then we have to search manually. We would like to run a query which compares families.famID to address.street so that where famId has more than one address attched it is returned to the results grid. Does this make sense? is it possible? Any help would be gratefully received
if you notice on the 8 and 9th rows the only difference between them is in the E column(0 and 1). What I am trying to do here is to display all with max(E). So in the above example, I should display rows 1-7,9,10 (8th row will not display because the 9th row has 1 in the E column). this is the query I have been using on SQL Server 2000 but I keep on displaying all the rows:
SELECT A,B,C,D,max(E) FROM <table> WHERE ( A = '012345A' ) AND ( B >= '01/01/2001' ) AND ( C <= '01/31/2001' ) GROUP BY A, B, C, D
ok, i'm building a page to display a list of courses, a user rating and 'last visited' date.
I have 3 tables - course (a list of all courses) review (a list of all ratings) visit (user visits to each course)
I've put together an SQL statment that returns everything i need, however its not quite right. SELECT course.courseID, course.courseName, course.courseURL, avg(review.fldRating) AS fldAverage, visit.visitDate FROM course
LEFT OUTER JOIN review ON course.courseId = review.fldcourseId
LEFT OUTER JOIN visit ON course.courseId = visit.courseId and visit.userId = 2
GROUP BY course.courseId, course.courseName, course.courseURL, visit.visitDate ORDER BY course.courseId, visit.visitDate DESC
The problem lies with the fact that each time a user enters a course a new record is inserted into the visit table - so the visit table will show how many times a user has entered a course and on which dates.
because the user has entered course 1 twice, the list is now showing 2 course1's - how can I change the statemtent to only select the most recent user visit, but still keep the complete list of courses?
I'm a bit of an SQL novice, so appologies if I've not explained this very well, Thanks in advance,
Hi, This is a really complicated issue and is hard to explain but i have the following:
select name, MAX(table2.time) from table1 INNER JOIN table2 on table1.id = table2.id GROUP BY name
which is fine and brings up the correct results but if I want to find out from those records what another field is in table 2 for each record it pulls up too many results (i want just the one result from table 2 and then find what user it is)
if I do..
select name, table2.username MAX(table2.time) from table1 INNER JOIN table2 on table1.id = table2.id GROUP BY name, table2.username
.. it pulls up too many results cos there are different usernames
if i dont group by table2.username then it give an error
Hello I am trying to gilter a table by getdate() (i also tried now()) but I cannot seem to be able to do it I place my code below if anyone can help. am grateful, my db is sql 2005.
<% Dim Recordset1__MMColParam Recordset1__MMColParam = getdate() If (Request("MM_EmptyValue") <> "") Then Recordset1__MMColParam = Request("MM_EmptyValue") End If %> <% Dim Recordset1 Dim Recordset1_cmd Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command") Recordset1_cmd.ActiveConnection = MM_connpeepeek_STRING Recordset1_cmd.CommandText = "SELECT usr_image1, dateimage_usr FROM diddle.ps_usr_image WHERE dateimage_usr = ?" Recordset1_cmd.Prepared = true Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 135, 1, -1, Recordset1__MMColParam) ' adDBTimeStamp
Set Recordset1 = Recordset1_cmd.Execute Recordset1_numRows = 0 %>
I am trying to filter data from columns and this is just not working. If I select all the criteria below and try to run it - I do not get any records returned.
WHERE (DropDt >= DATEADD(month, DATEDIFF(month, 0, GETDATE()) - 13, 0)) AND (DropDt <= DATEADD(month, DATEDIFF(month, 0, GETDATE()) - 1, 0)) and Type IN ('Employee', 'Refinance')
Hi, I have following query. I want to insert the value MBR_COV_EFF_DATE to table fixed_MM if the function dbo.CheckTheDate2 returns correct date and if it returns NULL I want to insert it on error_MM table. How can I do this?
select dbo.CheckTheDate2(MBR_COV_EFF_DATE,'MBR_COV_EFF_DATE') AS MBR_COV_EFF_DATE from [unfixed_MM]
VisitTimes Company 2007-07-10 14:24:38.000 Microsoft 2007-03-10 11:14:38.000 Microsoft 2007-12-01 13:04:56.000 SQLTeam 2007-12-13 12:54:52.000 GoldMan Sac 2007-08-11 02:15:38.000 Oracle 2007-02-11 12:45:04.000 SAP Ltd
I am asked to write a stored procedure that get a count of each count of visit on a START and END date I wrote the below SP but am not getting the right result I think the **where VisitTime >= @Start AND VisitTime <= @End)** is not being evaluated. Help pls
CREATE procedure dbo.GetVisits @Start varchar(50), @End varchar(50) as SELECT TOP 100 PERCENT COUNT(company) AS VisitCount, company FROM visits.dbo.IViewVisits where EXISTS (SELECT * FROM VISITS.dbo.IViewVisits where VisitTime >= @Start AND VisitTime <= @End) GROUP BY company ORDER BY COMPANY ASC
Hi Friends, i have a question table and i want to filter this table using the following stored procedure but i cannot take a resultset ; (there is no error)
Stored Procedure is here:
CREATE PROCEDURE [dbo].[SP$AllQuestion] @Session nchar(10), @Class nchar(10), @Unit nchar(10) AS BEGIN SELECT L.QID, L.CLASS, L.SESSION, L.UNIT, L.CONTENT as QUESTION FROM tblQUESTION L WHERE @Session IS NULL OR L.SESSION = @Session) AND (@Unit IS NULL OR L.UNIT = @Unit AND (@Class IS NULL OR L.CLASS = @Class) AND ((@Session IS NULL AND @Unit IS NULL ) OR (L.SESSION = @Session AND L.UNIT = @Unit)) AND ((@Session IS NULL AND @Class IS NULL ) OR (L.SESSION = @Session AND L.CLASS = @Class)) AND ((@Unit IS NULL AND @Class IS NULL ) OR (L.UNIT= @Unit AND L.CLASS = @Class)) AND (L.UNIT = @Unit AND L.SESSION = @Session AND L.CLASS = @Class) END
i dont know what my fault is ; to your opinion what i have to do? thanks from now on...
Hi, all:I'm having trouble with something that probably has a simple solution.I have linking tables that can list a particular MemberID multipletimes. Is there a way to run a query so that a specific ID will showup once?Here is an example of the tables I've set up --MemberTable:==MemberIDMemberName1Dave2John3MichaelFruitTable:==FruitIDFruitName1Apple2Orange3PearVeggieTable:==VeggieIDVeggieName1Carrot2Celery3Potato....and these linking tables --Members2Fruits:==MemberIDFruitID1213223132Members2Veggies:==MemberIDVeggieID1221222331This is the query I'm using to retrieve the ID's:SELECT distinct m.*, m2f.*, m2v.*FROM ((MemberTable m INNER JOIN Members2Fruits m2fON m.MemberID = m2f.MemberID)INNER JOIN Members2Veggies m2v ON m.MemberID = m2v.MemberID)WHERE ...By the way, I know of the GROUP BY clause, but it didn't work for me.Thanks for any help.J
Expression: =Fields!PRACTICE_ID.Value Operator: = Value: 20 and get this error: The comparison failed. Check the data type returned by filter expression.
Practice_id has int data type. How else can I check the data type returned by filter expression?
I tried to filter on table level the same way, and get the same error. Could anybody help, please, to make it work?
I am using the following SQL query in a SSRS 2005 report (see below). I need dbo.FilteredNew_Assets.new_assettypename = "Computer" ONLY when the value of dbo.FilteredNew_Assets.new_assignedemployeeid is NOT null. In other words, only when dbo.FilteredNew_Assets.new_assignedemployeeid has a value do I need dbo.FilteredNew_Assets.new_assettypename to be filtered.
Is this a task that needs to be accomplished within my SQL query or somewhere within the context of the actual report? Either way, how do I accomplish this? SELECT dbo.FilteredNew_Employee.new_employeeid, dbo.FilteredNew_Assets.new_assignedemployeeid, dbo.FilteredNew_Employee.new_employeetypename, dbo.FilteredNew_Employee.new_firstname, dbo.FilteredNew_Employee.new_lastname, dbo.FilteredNew_Assets.new_assettypename, dbo.FilteredNew_Assets.new_computertypename, dbo.FilteredNew_Assets.new_manufacturer, dbo.FilteredNew_Assets.new_model, dbo.FilteredNew_Assets.new_modelnumber, dbo.FilteredNew_Assets.new_assetsid, dbo.FilteredNew_Assets.new_name FROM dbo.FilteredNew_Employee LEFT OUTER JOIN dbo.FilteredNew_Assets ON dbo.FilteredNew_Employee.new_employeeid = dbo.FilteredNew_Assets.new_assignedemployeeid ORDER BY dbo.FilteredNew_Employee.new_lastname
I have the following below which works fine. However I would also like to filter on the group to say where the SumAmount is greater than 0 after the grouping occurs...
How would I do that? I guess I could put the results in a table variable and filter on that, but is there any other way?
Thanks
select grdproductvariant, psproduct, preAllocationBusUnit, preallocationdept, glaccountid, Sum(Cast(Amount AS Decimal(18,2))) As 'SumAmount'
from tblTransaction tbl
where periodinfile= '200710' and datasourceIdinfile = 'ADJ'
group by grdproductvariant, psproduct, preAllocationBusUnit, preallocationdept, glaccountid
I'm trying to add a filter on a table that gives the top 10 locations with the most readership (a measure). The table has to columns. 1st column gives location, 2nd gives readership count. On the table properties, I choose filter expression: Fields!Location.Value Operator: Top N Value: 10
However this gives an error "failed to evaluate the FilterValue"
I have an SSRS 2005 server report based on a stored procedure dataset, which accepts a single parameter. The parameter value originates from a session variable when the user opens the aspx page containing the reportviewer control (Visual Web Developer 2005). I've configured this parameter as a hidden parameter in the RDL design. In this configuration it functions as intended in both the development environment and when deployed.
Next, I tried to add user prompts to implement report server filtering (in addition to the database filtering in the source SPROC). I added the parameters, set up the data sources for the prompt values, set up the filter expressions, did everything that I can find to implement this process.
When I preview the report in the development environment, it works as intended.
When I deploy it and attempt to run it from my http://localhost environment, though, it fails. There's no error message or anything...I don't even get the "Report Running" icon with no rows returned...what I get is prompts which function correctly (showing the right values and letting me select one), but when I click "Run Report" I just get an immediate screen refresh with the prompts reset to the default "<Select a value>" setting. And no report.
I've obviously missed some setting somewhere, for it to work in dev but not when deployed. Any suggestions will be GREATLY appreciated.
I'm wondering if is is even possible in SSRS 2005....
Let's say a user opens up a report which has 10 columns nad the result set consists of 1000 rows. What they would like to do is to be ale to build a dynamic filter and apply it to the original report...
For example, our data is all user data. The report returns all 1000 customers. The users then want to be able to create a filter on let's say "last name is Johnson" and their state is MD and their account is more than 30 days old.
This is easily done in the dataset properties prior to run-time, but can this be done "on-the-fly"?