Aggregate Excluding Filtered Rows

May 14, 2008

I am trying to show aggregate information in a grouping and report footer. The details section has a filter applied successfully. For example, if there are three records and one should be filtered out, then only two display. However, the count function returns 3 instead of the desired 2. I have tried to set the scope parameter to body, the table name and every group name on the report. Either this has no effect or returns an error message stating that the appropriate scope isn't applied.

Does anyone know how to perform aggregate functions and exclude the filtered rows?

Thanks,
Dennis

View 3 Replies


ADVERTISEMENT

Excluding Rows On A Table While Importing

Jul 11, 2007

I'm using DTSWizard to import a table from my main database to Temp.



This is the SQL statement...



CREATE TABLE [tempdb].[dbo].[xlaANLsubscribers] (
[subscriberid] int NOT NULL,
[pwd] varchar(255),
[name] varchar(255),
[deliveryformat] int,
[email] varchar(255),
[gender] varchar(255),
[phone] varchar(255),
[country] varchar(255),
[city] varchar(255),
[state] varchar(255),
[zip] varchar(255),
[address] varchar(1000),
[dateregistered] varchar(50),
[bounces] int
)



What I'd like to do for example, is exclude the first 5,000 rows, and import the rest.

Should I be using something other than DTSWizard, and it there something that can be added to the statement above telling it to start at a specified row?



This is probably fairly simple, but I'm new at this and I'd sure appreciate the help.



Thanks,

Bill

View 16 Replies View Related

Integration Services :: SSIS Aggregate Group By - Duplicate Rows

Jul 8, 2010

I'm doing a group by in an aggregate transformation.  I have say 6 columns in the output and I'm grouping on all of them - how can I get duplicate rows in the output?  If I do the same select and group by in SQL on the source data I don't get any duplicate rows.  In fact out of 6000+ rows I only get 2 duplicates.

View 7 Replies View Related

Cannot Perform An Aggregate Function On An Expression Containing An Aggregate Or A Subquery.

Oct 19, 2007

Can any1 tell me why i am getting an error


SELECT DISTINCT

--p.voucher,

--p.amount,

p.siteID,

b.siteID,

SUM((round(b.total,2,2)) - SUM(round(p.amount,2,2))) AS OutStandingBalance,

SUM((round(b.total,2,2)) - SUM(round(p.amount,2,2))) AS CashCheque,

SUM((round(b.total,2,2)) - SUM(round(p.amount,2,2))) AS Vouchers

FROM

BillingTotal b,

Payment p

--WHERE

-- s.sitename=@cmb1

--AND p.siteid = s.siteid

-- p.voucher = 0

-- p.voucher = 1

GROUP BY p.siteID,b.siteID



Msg 130, Level 15, State 1, Line 1

Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

View 8 Replies View Related

Analysis :: Calculated Member From Aggregate And Non-aggregate Factors

Sep 22, 2015

I have 2 Dimensions in SSAS (see below end), I want to create a calculated member, named

This_Year_Billable_Objective_Count, with its formula = BillableLastYear*(100+ BillableObjective)/100.

The first factor,  BillableLastYear is a number, aggregated (sum) from child units.

The second factor,  BillableObjective is a percent number (for example 28 means 28%), it's not aggregate. It's an dependent value for each unit.

How can I calculate This_Year_Billable_Objective_Count for each unit?

\ able 1
SELECT [UnitKey]
      ,[UnitID]
      ,[UnitName]
      ,[Unit2Name]
      ,[Unit3Name]
      ,[Unit4Name]

[Code] .....

View 6 Replies View Related

Number Of ROWS Of Output Of Aggregate Transformation Sometimes Doesn't Match The Output From T-SQL Query

Dec 25, 2006

While using Aggregate Transformation to group one column,the rows of output sometimes larger than the rows returned by a T-SQL statement via SSMS.

For example,the output of the Aggregate Transformation may be 960216 ,but the

'Select Count(Orderid) From ... Group By ***' T-SQL Statement returns 96018*.

I'm sure the Group By of the Aggregate Transformation is right!



But ,when I set the "keyscale" property of the transformation,the results match!

In my opinion,the "keyscale" property will jsut affects the performance of the transformaiton,but not the result of the transformation.

Thanks for your advice.

View 2 Replies View Related

Filtered Where Clause

Feb 1, 2012

I need to include pre k kids in the is script for one school and exclude them for the others. I have them all excluded with the last statement in the where clause. How would I go about accomplishing this.

Code:
SELECT DISTINCT
C.Student_ID,
isnull(left(dbo.capfirst(rtrim([first_name])),12),' ') as First_Name,
isnull(left(dbo.capfirst(rtrim([last_name])),17),' ') as Last_Name,
LEFT(Middle_Name, 1) as Middle_Initial,
RTRIM(CONVERT(CHAR,Birth_Date,101)) AS DOB,

[Code] .....

View 2 Replies View Related

Filtered Joins

Jul 23, 2005

I am having some difficulty in constructing outer joins. I havesimplified what I need to do and have included sample SQL statements:create table tab_a (id int, descr varchar(10), qty int)insert into tab_a values (1, 'item one', 10)insert into tab_a values (2, 'item two', 20)insert into tab_a values (3, 'item three', 30)insert into tab_a values (4, 'item four', 40)create table tab_b (id2 int, descr2 varchar(10), qty2 int)insert into tab_b values (1, 'item one', 10)insert into tab_b values (2, 'item two', 20)insert into tab_b values (3, 'item three', 30)insert into tab_b values (4, 'item four', 40)Here is the statement that I have:SELECT tab_a.id,tab_a.descr,tab_a.qty,tab_b.id2,tab_b.descr2,tab_b.qty2FROM tab_a LEFT OUTER JOIN tab_bON (tab_a.id = tab_b.id2 )WHERE tab_a.qty <= 30 ANDtab_b.qty2 > 20What I am trying to do is left outer join between tab_a and tab_b afterthey have been filtered based on the qty column. (for tab_a: qty <=30; and for tab_b: qty > 20).How would I go about that? I would like to do this efficiently sincethe two tables have about a million records and several other columnseach.

View 5 Replies View Related

Filtered Out Code

Jul 20, 2005

Hi all,I’m a bit new to this so hope this is not too obvious!I am running a query like so (simplified form)Select Cus_no, Cust_Name, course_idWhere Cust_id = 2From course tableHowever not all the Cust_Id’s have been entered therefore so using a twofilters out the information I might need.Is there a way I can get around this?Many thanksSam*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 2 Replies View Related

Filtered Data And SQLDatasource

Apr 21, 2008

In asp.net 3.5.....
To get the number of rows returned when the select is executed.......
 Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Selected        Session("MessageText") = e.AffectedRows & " Profile(s)"End Sub
How do you get the number of rows returned when you apply a filter expression to a selection of rows?
Thanks
Craig

View 3 Replies View Related

Process Filtered Set Of Records

May 15, 2013

I have a table in SQL 2012 where we add records on daily bases. A col is for user name.

I want to select records with each user and send the same to that user with db mail.

I have worked with VB but I am totally new in this field.

View 12 Replies View Related

Multiplying 2 Columns And Filtered By A 3rd

Aug 7, 2014

I am trying to multiply 2 columns and filtered by a 3rd.

View 3 Replies View Related

Sql Server Uses Data Which Was Filtered Before

Apr 11, 2007



I got this table named 'Streets':







Street (varchar)
PLZ (varchar)

'A'
'?'

'B'
'1'



SELECT * FROM (

SELECT * FROM (

SELECT Strasse,PLZ FROM Streets

) SUB WHERE IsNumeric(PLZ) = 1

) SUB WHERE PLZ = 1



I always receive this error:

Conversion failed when converting the nvarchar value '?' to data type int.



How must the statement look like, to execute this successfully?

I also tried to use a view which returns only valid streets, also a function, but it seems sqlserver tests the row with the '?' anyways



PLZ HELP!



PS: If you want to try it, create the table because using the following instead the table works fine:



SELECT 'A' as Street ,'?' as PLZ

UNION

SELECT 'B','1'

View 9 Replies View Related

Report Using CRM Filtered Views, Sub-Report Not Using Filtered Views

Oct 19, 2007



Hello Everyone,

I'm just trying something that I haven't tried before, and I'm wondering if anyone has done it before. I'm building a report with three charts. This chart is going to go inside of Microsoft CRM. One of the charts has to use CRM filtered views, so that a manager can see his whole team's numbers, but a team member will only see his numbers. I can't do this any other way because of the complexity of the query, which has 3 select statements joined together as tables. It would be too complex to try to use a parameter throughout all of those tables, and I'm not sure how I would set up a parameter to show all of the data if the user were the manager, and only the single user's data if it were someone else.

The other two charts use filtered views as well, but they have similar joins, and I had to hard code a column with meaningless data into each SELECT table so that I could use it to join, as the tables had no other similarities.

The problem is that when you upload a report into CRM, if it uses filtered views, you don't have to go into Report Manager and change the data source from a shared to a custom data source. But on reports where I don't use the filtered views, I find that they always break when upload them, because they use the shared data source. This is the case even when I have created the report without the shared data source. So I usually have to go in and change the data source from shared to custom every time I upload a report without filtered views.

Because of the situation I described, this report uses both filtered views and non-filtered views (for the hard-coded columns). When I upload it into CRM, it won't work either way, with a shared or a custom data source.

Has anyone had this problem before?

View 1 Replies View Related

Excluding Records

Apr 24, 2008

Hello,

I'm trying to figure out the best way to approach this seemingly simple task in Reporting Services 2005, but have come up with nothing but frustration. Any help would be appreciated!

Here's the basic idea:

SELECT Server.Database1.Employee, Server.Database1.HomeDept, Server.Database2.WorkedDept
FROM Server.Database1, Server.Database2

I need to exclude certain combinations of HomeDept/WorkedDept (about 11)...such as 1015/2223, 1015/2226, 2002/4422, 2002/8742, 2002/2342, etc. I want any other combinations of HomeDept 1015 & 2002 to be selected (which would be hundreds).

I've tried:

WHERE (Server.Database1.HomeDept <> '1015' AND Server.Database2.WorkedDept NOT IN ('2223','2226')) AND Server.Database1.HomeDept <> '2002' AND Server.Database2.WorkedDept NOT IN ('4422','8742','2342'))

(and all combinations of NOT IN, <>, and parenthesis placement...I even tried to do each exception separately)

What happens is that all instances of HomeDept 1015 and 2002 and all instances of WorkedDept 2223, 2226, 4422, 8742, and 2342 are excluded.

The SQL Query Designer will remove parenthesis so that the HomeDept exclusion is processed separately from the WorkedDept.

I've tried to do the SQL in the Generic Query Designer, so the SQL Query Designer doesn't reformat it, and it still returns the same results.

This behavior only seems to happen when using <> for both, NOT IN for both, or a combo of NOT and <>. If I used = for the HomeDept, the exclusion of the WorkedDept worked fine.

Any suggestions?

View 1 Replies View Related

Excluding Value From Insert

Jun 17, 2014

The script basically maps ALL products to customer levels. The Delete statement at the start is needed to make sure that any deleted products or temporary mapped products are removed once a week. However I want to map some products to CustomerID's 9,10 and 14 only. But when I run this statement it maps all products to all customer levels. What I want is thisAll products mapped to customer levels 9,10 and 14Then every other product mapped to customer levels 0,5,7, and 8 but not those extra ones in 9,10 and 14.

DELETE FROM ProductCustomerLevel
WHERE CustomerLevelID IN (0, 5, 7, 8, 9, 10, 14)
INSERT ProductCustomerLevel
(
ProductID,
CustomerLevelID

[code]....

View 5 Replies View Related

Excluding Duplicates

Nov 20, 2007

I have to exclude some records from the data flow.

If there is more than one record with equal col1 and col2, I need to exclude both records.

I can't do this operation in the OLE DB Source because I have to run some transformations before I run the col1-col2-equality check.

ANy ideas? Is aggregation transformation way to go? How do I tell to the aggr. transf to do a having count() > 1?

View 3 Replies View Related

SQL 2012 :: Filtered Indexes In Server

Aug 14, 2014

What are driving criteria for creating filtered indexes on SQL server. I am trying to analyze the index stats through DMV,histogram and have to analyze if the filtered indexes should be created on tables. This exercise has to be done for all the transaction tables on the database. What are the approaches I should be looking on?

There was a deadlock on the DB because of huge writes on one of the big tables. Having filtered index on this table for the effected column would reduce the time taken for write operations. Hence we are looking for creating filtered indexes appropriately

View 8 Replies View Related

SQL 2012 :: Removing Columns That Are Filtered?

Aug 5, 2015

I have a query that I'm filtering using Customer ID, CustomerID = '12345', even though I need the query to filter that data, I don't need to see that column in my results. I tried removing it from my Select Distinct group but I'm guessing it needs to be there or the filter won't work(like I said, very green). Is there something that I can add to hide this column?

SELECT DISTINCT
RG.ResNumber,
ResWithSupp.SupplierID,
ResWithSupp.ServiceType,
RG.CustomerID,

[code]......

View 4 Replies View Related

Linking Filtered Result To Subreport

Feb 16, 2008

I am relatively new to SSRS and having some problems showing the right results from my subreport. I am using a cube for my datasets. I have created a report parameters where I can filter out year and months to see the sales in certain month. I also want to add a calculation to display the sum for the choosen period.

f.exs. if I choose january 2004 my result look like this:

Key Product Amount
41999 prod. x 5,000
42999 prod.y 2,000

Totals: [results from subreport showing total of 7,000]

What I would like to do is to add a total that calculates the total according to the filter. I tried to add a subreport beneath, but I don´t know how to link the filtered condition to the subreport, so it displayes always the total amount for all years from the cube.

Hope there is some neat way to do this

View 2 Replies View Related

Roll Up Filtered Detail Group

Apr 4, 2007

I the following report with one group:





Month Number of Sales Total Sales



+ Jan 2007 100 $1,000.00



When you dril down on MonthYear you get the detail data:





Month Number of Sales Total Sales



- Jan 2007 10 $610.00

1 $10.00

1 $20.00

1 $30.00

1 $40.00

1 $50.00

1 $60.00

1 $70.00

1 $80.00

1 $100.00

1 $150.00



My question is. I added a filter to the detail data to give the Bottom % =75 of sales. So My detail data only displays the following rows:



Month Number of Sales Total Sales



- Jan 2007 10 $610.00

1 $10.00

1 $20.00

1 $30.00

1 $40.00

1 $50.00



My problem is the group still displays the total of my dataset (as seen above), but I want it to display the total of the detail data group, like below:



Month Number of Sales Total Sales



- Jan 2007 5 $150.00

1 $10.00

1 $20.00

1 $30.00

1 $40.00

1 $50.00



If I change the fields in the group to look at the detail data ,for instance =count(Fields!NumberofSales.Value,"Details_Group") I get an scope error.



How can I display the totals of the detail data in the parent group after I added a filter to the detail data?







View 6 Replies View Related

Matrix Group Cannot Be Filtered Using OR Predicat

May 16, 2008

Hi

I've been surprised with upleasant issue in RS Matrix group.

I've tried to filter Matrix group but failed in using "OR" predicat in Filter expression:


ScreenShot

"AND" is used by default despite of header "And/Or" which is disabled!


How can I use "OR" ?

Andriy Zhornyk

View 1 Replies View Related

Excluding Empty Parameters

Apr 17, 2005

I would like to exclude any parameter that is empty from the SELECT
command?  How do I do this?  This is part of a stored
procedure.

SELECT PersonID FROM Persons WHERE
(FirstName = @firstname) AND
(LastName = @lastname) AND
(SSN = @ssn) AND
(AddressID = @addressid) AND
(DOB = @dob) AND
(Middle = @middle)

THanks

View 2 Replies View Related

# Of Weekdays Between Dates Excluding Sat/Sun

May 14, 2002

Does anyone know how to write code to tell the amount of days between 2 dates excluding Saturday and Sunday.
Datediff will tell me the total amount of days and I guess I need some logic to look at the startdate and manipulate the total after the fact.

Any thoughts or solutions out there?

View 4 Replies View Related

Excluding Duplicate Records

Apr 18, 2008

and generating a report from an SQL table, and need to know how to exclude records that are "duplicates". Not duplicates in a sense that every field is identical, but duplicates in a sense where everything except the unique identifier is identical. Is there a quick and easy way to do this?

View 5 Replies View Related

Excluding Data For Certain Criteria Only

Feb 6, 2012

I'm having a problem writing a SQL query that excludes certain data. This is for a pay stub application to display current and previous paycheck stubs. To calculate certain data such as YTD figures and time off, we SUM on other tables. However, to display correctly, I can't SUM bonus checks for the current payperiod ONLY - but for previous pay periods, I must SUM bonus checks.

Here's an example of my data:

No code has to be inserted here.
No code has to be inserted here.

No code has to be inserted here.
No code has to be inserted here.

Right now my SQL is this:

Code:
SELECT PR04PTF.PayCheckNo, SUM(PR11ERF_History.PayCheckAmt) AS [TotalSum]
FROM PR04PTF

INNER JOIN PR11ERF_History ON
PR11ERF_History.EmployeeID = PR04PTF.EmployeeID
AND PR11ERF_History.PayPeriodEnd <= PR04PTF.PayPeriodEnd

WHERE PR04PTF.EmployeeID=441

View 3 Replies View Related

Order By Excluding First X Characters

Jul 6, 2012

I have a column where records are either 6 or 7 characters long.

for example:

111.111

OR

111.01

I am trying to order by the characters after the period. In other words I would like to exclude the first 4 characters (the 111.)

View 1 Replies View Related

Duplicate Row Excluding Primary Key

Jul 6, 2007

I am trying to duplicate a row in a table and this is the solution I came up with:

CREATE PROC duplicate_row(@my_primary_key)
AS

DECLARE @sql_stmt varchar(MAX)
SET @sql_stmt = 'INSERT INTO My_Table('

SELECT@sql_stmt = @sql_stmt + COLUMN_NAME + ','
FROMINFORMATION_SCHEMA.COLUMNS
WHERETABLE_NAME = 'My_Table'
ANDCOLUMN_NAME NOT IN ('my_primary_key','title')

SET @sql_stmt = @sql_stmt + 'title) SELECT '

SELECT@sql_stmt = @sql_stmt + COLUMN_NAME + ','
FROMINFORMATION_SCHEMA.COLUMNS
WHERETABLE_NAME = 'My_Table'
ANDCOLUMN_NAME NOT IN ('my_primary_key','title')

SET @sql_stmt = @sql_stmt +' title+''_copy'' AS title FROM My_Table WHERE my_primary_key = '+LTRIM(STR(@my_primary_key))

EXEC(@sql_stmt)

However this stored proc is horrifically slow. I was wondering if anyone had any suggestions on a better way to accomplish this.
-thanks

View 5 Replies View Related

Group By By Excluding Prefix

Apr 12, 2006

Suppose there is a table containing these recodes.country-------CON_CHNCON_JAPJAPCON_CHNWhen I use the following sql:select country, count(*) as num from table group by countrythe normal result will be:country num---------------CON_CHN2CON_JAP 1JAP1However, my desired result is as follows:country num-----------------CON_CHN2CON_JAP 2How can I re-write my SQL? Or any other methods to do that?

View 2 Replies View Related

Excluding Repeated Values In A Sum

May 21, 2007

The scenario is as follows:

I have rows coming from the db including:
Contract Number, Contract Name, owner and Actions associated with each contract.

SQL statement brings back:
Contract Number Contract Name Sales Owner Action
1234 123453 $50 Neil x
1234 123453 $50 Bob y
534232 5464634211 $30 Harry z

The problem is that each contract can have multiple actions associated with it...
There ideal output would be:

Contract Number Contract Name Sales Owner Action
1234 123453 $50 Neil x
Bob y
534232 5464634211 $30 Harry z

Total: $80

Basically I need to hide and not include repeated items based on a contract number... one idea I had was creating a group based on contract number and then display info in the header and then only owner and actions in the detail section.. The problem is Totals... how can I can it to avoid count the duplicated values..

Any help would be greatly appreciated.

Thanks,
Neil

View 4 Replies View Related

Excluding Duplicates After Multicast

Sep 25, 2007

I have to do various controls on a dataset - I created a multicast. After performing controls (one control per copy), I merge my (7) multicasted datasets using a Union All transformation. The problem I'm having are the duplicate rows created by merging the multicast copies.

How do I get rid of the duplicates? Is the Sort Transformation the solution by setting the option Remove rows with duplicate sort values to True? I have a unique key by which I'm able to discard the duplicates correctly. Are there any other ways (at a Union All level)? Is there sth like Union and Union All like in SQL?

I'm working on my 1st integration serv. project and it seems that more I work more questions I have. Shoudn't be the opposite? Thank you for the help.

View 3 Replies View Related

Request Stored Procedure Filtered By Today

Sep 6, 2006

I am using SQL2005.There si a field called"EXPDATE". I need a query that shows the table info, if the date that is exist on "EXPDATE" is greater than today. In summary How to write a code that if EXPDATE> "today (I do not know what to put instead of today)" then show the contents of date

View 2 Replies View Related

SqlDataSource Filtered By Users' Username - What's The Syntax???

Jan 23, 2007

Hi
I need to create an sqlDataSource that filters a table based on the users ID – in other words, I have a table with a list of users, and when a logged in user loads the page, the results should only show records with their user name.
How would I do this?
Thanks for any help in advanceRichard

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved