Data Access :: How To Do Grouping Using Three Columns

Oct 7, 2015

I am using sql table named as product which is having columns partno,partnm,weight,surfacearea,totalhr,type

I want sum of weight,surfacearea,totalhr and grouping on partno,partnm,type

If I use query select partno,partnm,sum(weight),sum(surfacearea),sum(totalhr) from product GROUP BY partno,partnm then its working correctly with sum and grouping but if I use query select partno,partnm,sum(weight),sum(surfacearea),sum(totalhr),type from product  GROUP BY partno,partnm,type then it is not grouping as expected.

why if  third column included in group by clause its not working correctly...Is there any way to group as I want.

View 9 Replies


ADVERTISEMENT

Data Access :: Merging Two Rows In Two Columns

Jul 8, 2015

I have a table data as shown below.

IDFNLN
1x
1y
2a
2b
3g
4t

I want output as shown below.
  
IDFNLN
1xy
2ab
3g
4t

I want the two duplicate rows to be merged into one. How to achieve it.

View 10 Replies View Related

Grouping 2 Columns Into 1!

Apr 21, 2004

HI,

i have 2 columns named firstname and lastname, i need to get them into 1 column named name with a space between them.
Does anyone have a tip to do this?

Wimmo

View 2 Replies View Related

Grouping Columns

Jul 23, 2005

Hi,I was trying to retrieve some data in such a way that it 2 columns willbe merged into one, with a column in between. I am trying to dosomething like this:SELECT LastName + ", " + FirstName AS NameFROM EmployeeTBLORDER BY LastNameBut SQL Server does not like this syntax (though it does work with"LastName + FirstName").I appreciate any help.Thanks,Aaron

View 4 Replies View Related

Data Access :: Retrieve Schema Information Of Columns Of Tables

Sep 10, 2015

Till recently we were using the following code to retreive schema information of columns of tables

Dim schemaTable = connection.GetOleDbSchemaTable( _
System.Data.OleDb.OleDbSchemaGuid.Columns, _
New Object() {Nothing, Nothing, tableName, Nothing})

Now instead of getting the name of table (which i was using as param for filtering) i'm going to receive a sql-query. Now my question is if I were to get a query like the following :

SELECT
[EmployeeID],
[Title] + ' ' + [LastName] + ' ' + [FirstName] AS FullName,
[BirthDate],
[Address],
[City] + ', ' + [Region] + ', ' + [Country] + ' - ' + [PostalCode] AS FullAddress
FROM [dbo].[Employees]

Then how can I retrieve the schema information of only the columns present in the query.

(Its possible that i might get a query with multiple tables with joints)...

View 3 Replies View Related

Problem Grouping By Columns

Jul 30, 2007

Hello guys !!

I'm actually a Mysql user, not a SQL Server user, just becouse the business I work uses it. But the problem I've had I think doesn't have any relation on the plataform it's running...

This is a construction software... I'll try my best to explain you : My table has 4 main columns (Face,Station,Combination,sAs). Face , Station and Combination form a primary key (never repeat together) and the "sAs" represents a calculus between some parameters.

The problem (it became a challenge already :D) consists in selecting the Face,Station and Combination where sAs is maximus, BUT grouping ONLY Face and Station.

For example :

Face Station Combination sAs
F1 0 Comb1 45
F1 0 Comb2 13
F1 0 Comb3 30
---
F1 10 Comb1 42
F1 10 Comb2 60
F1 10 Comb3 12
---
F2 0 Comb1 32
F2 0 Comb2 15
F2 0 Comb3 01
---
F2 10 Comb1 02
F2 10 Comb2 07
F2 10 Comb3 23


Here is the challenge :
If you execute the following query : "select Face,Station,Combination,max(sas) as sAS from test group by Face,Station" it returns you an arbitrary Combination for the rows in the resultset.

Face Station Combination sAs
F1 0 Comb1 45
F1 10 Comb1 60
F2 0 Comb1 32
F2 10 Comb1 23

But the combination I'd like to have is the combination related to the maximus sAs in F1/10, Comb2 instead of Comb1 returned..... The same occurs with the last row F2/10.


The query I wanna find should return the following resultset.

Face Station Combination sAs
F1 0 Comb1 45
F1 10 Comb2 60
F2 0 Comb1 32
F2 10 Comb3 23



Please, if somebody has any idea, share it to help me....

Thanks a lot..

Rodrigo

Some code to make it easier to try.... Maybe it has some difference between SQL Server and MySQL.

////////////// CUT HERE

create table test(
Face varchar(20),
Station int,
Combination varchar(20),
sAs int
);

insert into test values('F1', 0, 'Comb1', 45);
insert into test values('F1', 0, 'Comb2', 3);
insert into test values('F1', 0, 'Comb3', 30);
insert into test values('F1', 10, 'Comb1', 42);
insert into test values('F1', 10, 'Comb2', 60);
insert into test values('F1', 10, 'Comb3', 12);
insert into test values('F2', 0, 'Comb1', 32);
insert into test values('F2', 0, 'Comb2', 15);
insert into test values('F2', 0, 'Comb3', 01);
insert into test values('F2', 10, 'Comb1', 02);
insert into test values('F2', 10, 'Comb2', 07);
insert into test values('F2', 10, 'Comb3', 23);

select Face,Station,Combination,max(sas) as sAS from test group by Face,Station;
////////////// CUT HERE


Rodrigo Bornholdt

View 3 Replies View Related

Combining Columns And Grouping By....

Jul 20, 2005

Hi,I have the following SQLSELECT Table1.Col1, Table3.Col1 AS Expr1,COUNT(Table1.Col2) AS Col2_No, COUNT(Table1.Col3) AS Col3_No etc,FROM Table3INNER JOIN Table2 ON Table3.Col1=Table2.Col1RIGHT OUTER JOIN Table1 ON Table2.Col2=Table2.Col2GROUP BY Table1.Col1, Table3.Col1The output rows have a value in either Table1.Col1 or Table3.Col1 but notboth.I'd like to combine Table1.Col1 and Table3.Col1 and group by the combinedcolumn in the result but don't know how.Thanks gratefully

View 5 Replies View Related

Grouping Columns From Select Statement

Jan 23, 2015

I am retrieving some data from Invoices, Customers and Companies tables as follows, but would like to make the customerName and the Companies.Name as single column such Name and similarly for customerID/companyID and customerCode/companyCode.

Code:
with cte
as
(
selectdistinct i.invoiceNumber, itemID, customers.customerID, Companies.companyID
,SUM(net_weight) as totalWeight, rate
,(select SUM(net_weight) * rate) as amount

[code]....

View 6 Replies View Related

Grouping Columns In A Varaiable When Using PIVOT?

Jan 23, 2008


Hi,
I just read on web that we can not use grouping columns in a variable when using PIVOT operator. For example like,
USE AdventureWorks
GO
SELECT VendorID, [164] AS Emp1, [198] AS Emp2, [223] AS Emp3, [231] AS Emp4, [233] AS Emp5
FROM
(SELECT PurchaseOrderID, EmployeeID, VendorID
FROM Purchasing.PurchaseOrderHeader) p
PIVOT
(
COUNT (PurchaseOrderID)
FOR EmployeeID IN
( [164], [198], [223], [231], [233] ) // cannot put these in a variable like @Col
) AS pvt
ORDER BY VendorID;



Though it can be achieved using when making the query using dynamic sql. If some can make it clear why it is possible using dynamic sql and not with the above code.

Regards,

View 4 Replies View Related

SQL Server 2012 :: Grouping Columns In Table

Sep 15, 2015

I have table like below.

filename col1 col2 col3
ABD Y NULL Y
XYZ Y Y Y
CDZ Y Y Y

I Need a output like this

filename col1 col2 col3 Group
ABD Y NULL Y Group1
XYZ Y Y Y Group2
CDZ Y Y Y Group2

I wanted to group the col1 , col2, col3 and group it as same group.

View 3 Replies View Related

Select With Grouping For Multiple Date Columns

Sep 22, 2007

Hi All,

Thanks for dropping by my post.

I have a table which is of this form.










ID
MS030_A
MS030_F
MS036_A
MS036_F
MS040_A
MS040_F

ZZ0023
2/16/06
2/16/06
8/10/07
8/10/07
11/21/05
11/21/05

ZZ0031
8/10/07
4/5/07
8/9/07
8/9/07
3/22/07
3/22/07

ZZ0077
8/9/07
9/7/07
8/10/07
8/10/07
8/10/07
9/7/07

ZZ0078
8/10/07
9/7/07
8/9/07
8/9/07
8/9/07
9/7/07

ZZ0079
8/9/07
8/10/07
10/26/05
10/26/05
8/10/07
8/10/07

ZZ1030
3/31/05
8/10/07
9/1/05
9/1/05
8/9/07


ZZ1033
3/24/06
8/9/07
8/9/07
8/9/07
3/31/05


ZZ1034
8/10/07
8/10/07
8/9/07
8/9/07
3/24/06


ZZ1037
8/9/07
8/9/07
9/24/07

9/24/07


ZZ1040
10/26/05
10/26/05
9/24/07

9/24/07


ZZ1041
9/1/05
9/1/05
9/24/07

9/24/07


ZZ1042
8/9/07
8/9/07
9/24/07

9/24/07
11/21/05

The goal is to group all this transactions by Month and Year.

Something like this....







MS030_A
MS030_F
MS036_A
MS036_F
MS040_A
MS040_F
Month
Year

3
2
2
2
2
2
1
2006

4
4
7
9
8
9
2
2006

10
10
6
8
8

3
2006

4
4
5
5
3
2
4
2006

5
6
8
3
7
1
5
2006
For just one date column it is pretty straight forward i.e., just do a select count and group by DATEPART ( Mm, DateField)
but for multiple columns i am in a total fix....

can please someone help me out...

appreciate your help

View 6 Replies View Related

Reporting Services :: Develop SSRS Report Based On Grouping Of Certain Columns

Sep 1, 2015

I want to develop a ssrs report which is grouped by month?

View 4 Replies View Related

SQL Server 2012 :: Data Grouping On 2 Levels But Only Returning Conditional Data

May 7, 2014

I think I am definitely thrashing and am not getting anywhere on something I think should be pretty simple to accomplish: I need to pull the total amounts for compartments with different products which are under the same manifest and the same document number conditionally based on if the document types are "Starting" or "Ending" but the values come from the "Adjust" records.

So here is the DDL, sample data, and the ideal return rows

CREATE TABLE #InvLogData
(
Id BIGINT, --is actually an identity column
Manifest_Id BIGINT,
Doc_Num BIGINT,
Doc_Type CHAR(1), -- S = Starting, E = Ending, A = Adjust
Compart_Id TINYINT,

[Code] ....

I have tried a combination of the below statements but I keep coming back to not being able to actually grab the correct rows.

SELECT DISTINCT(column X)
FROM #InvLogData
GROUP BY X
HAVING COUNT(DISTINCT X) > 1

One further minor problem: I need to make this a set-based solution. This table grows by a couple hundred thousand rows a week, a co-worker suggested using a <shudder/> cursor to do the work but it would never be performant.

View 9 Replies View Related

Data Access :: MS Access ADODB Connection To Stored Procedure - Cannot Retrieve Data

Sep 22, 2015

I'm trying to re-write my database to de-couple the interface (MS Access) from the SQL Backend.  As a result, I'm going to write a number of Stored Procedures to replace the MS Access code.  My first attempt worked on a small sample, however, trying to move this on to a real table hasn't worked (I've amended the SP and code to try and get it to work on 2 fields, rather than the full 20 plus).It works in SQL Management console (supply a Client ID, it returns all the client details), but does not return anything (recordset closed) when trying to access via VBA code.The Stored procedure is:-

USE [VMSProd]
GO
/****** Object: StoredProcedure [Clients].[vms_Get_Specified_Client] Script Date: 22/09/2015 16:29:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON

[code]....

View 4 Replies View Related

Need Help In Grouping The Data

Jul 6, 2004

Hi all,
Hope u could help me

I have a table as follows

SupID | Week | ..| ........
-------------------------
234 1/2/03
235 1/2/03
236 2/2/03
237 2/2/03
238 2/2/03
239 3/2/03

and

I need to display theses data like

1/2/03(week)
-------------
234
235
2/2/03(week)
-------------
236
237
238
3/3/03(week)
-------------
239

If i go for Group by clause (SQL) then I can group them by week but cant display the individual rows.
Is there any way to do this (better if in a single query)

Thnx

View 3 Replies View Related

Grouping Data

Mar 11, 2004

some one plz help me.
I had a table with these columns.
Table(Id int,Name varchar,Value Varchar).
I have to group them by ID and each Name becomes column name of the new table

ex:-
Id Name Value
--------------------
1 x a1
2 x a2
3 x a3
1 y b1
2 y b2
3 y b3
1 z c1
2 z c2
3 z c3

I need it in this way

x y z
------------
a1 b1 c1
a2 b2 c2
a3 b3 c3


(no of columns in the new table can't be pre determined)


and which one would be better option to do this
in VB.Net code or in a Storedprocedure?

View 14 Replies View Related

Grouping XML Data

May 21, 2014

I am joining multiple tables and my result is following:

UserGroup UserName
UG1 Tom
UG1 Harry
UG2 Albert
UG3 Jim
UG3 Sam

I want xml in following format:

<UserGroupsInfo>
<UserGroups>
<UserGroup name="UG1">
<User>
Tom

[Code] ....

I have tried all combinations of for xml path but no success yet.

View 7 Replies View Related

Grouping Data

Mar 26, 2008

I have a set of data that contains duplicates and I am running a group by query to get a unique set of rows.

The group by works upto a certain state, but I need to be able to tell it to take the first appearance of an address field as you can in Access?

current query is:

select ID,Address1,max(value)
from test
group by id,address1

I have tried using First(Address1) but it doesn't recognise that as a function?

View 3 Replies View Related

Grouping Data

Feb 9, 2007

Hi Exports

I have a simple question, but I can't seem to get around it. Please help.

I have a table like this: [select * from Enrollment]
Course ID PersonID Role
BCC110 123 Student
BCC110 321 Student
BCC110 456 teacher
BCC123 457 Student

and I want to have a report like

Course ID Total Students Total Teachers
BCC110 2 1
BCC123 1 0

How do I achieve this?

Sam

View 8 Replies View Related

Data Grouping

May 8, 2007

hi,



I want to group data in matrix column. Lets say i have a field say Weekday which has weekdays from monday to friday. then suppose i have measure "my expenditure".

I will place Weekdays in column field of matrix and "my expenditure" in data field". lets not worry about rows.



Now i want something like this.

Group my expenditure in three categories like

1. My expenditure on monday

2. My expenditure on tuesday

3. My expenditure on days other than monday and tuesday.(means it should show me data for wednesday,thursday,friday and also if no weekday is entered)



what I am doing now is i m writting IIF expression in the column field but with that i get data for monday and tuesday but data for all the other days is not getting clubbed.



how can i do this?



Thanks

rohit

View 2 Replies View Related

Grouping Data

Feb 8, 2008

Hi Everyone,

I am trying to develop a report query that will dynamically group the data by day,week, quarter, month, or year. The user will select the interval from the site and pass it to the query. The query will convert the date field using a function I created. Is this the most efficient way to do this?

QUERY
------------------
SELECT dbo.FormatDate(DateCreated,3) As DateCreated, Count(*) As NumOfCalls
FROM Agent.LeadTracker
WHERE DateCreated BETWEEN '1/1/2008' AND '2/7/2008'
GROUP BY dbo.FormatDate(DateCreated,3)



RESULT
------------------
DateCreated NumOfCalls

2008-02-01 5442
2008-01-01 14150




FUNCTION------------------
CREATE FUNCTION [dbo].[FormatDate]
(
@Date datetime,
@Time int
)
RETURNS datetime
AS
BEGIN
DECLARE @Res datetime
IF @Time = 1 --Day
SELECT @Res = DATEADD(day,DATEDIFF(day,0,@Date),0)
ELSE IF @Time = 2 --Week
SELECT @Res = DATEADD(week,DATEDIFF(week,0,@Date),0)
ELSE IF @Time = 3 --Month
SELECT @Res = DATEADD(month,DATEDIFF(month,0,@Date),0)
ELSE IF @Time = 4 --Quarter
SELECT @Res = DATEADD(quarter,DATEDIFF(quarter,0,@Date),0)
ELSE IF @Time = 5 --Year
SELECT @Res = DATEADD(year,DATEDIFF(year,0,@Date),0)
RETURN @Res
END

View 4 Replies View Related

Query Or Grouping Problem (some Kind Of Parallel Grouping?)

Nov 26, 2007

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:

WO WOL WOLR WOLD
226952 10000 10000 10000
226952 10000 10000 20000
226952 10000 10000 30000
226952 10000 10000 40000
226952 10000 20000 10000
226952 10000 20000 20000
226952 10000 20000 30000
226952 10000 20000 40000
399999 10000 NULL 10000
375654 10000 10000 NULL
etc


Hierarchy:
WO > WOL > WOLD
WO > WOL > WOLR

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_]

View 1 Replies View Related

Transact SQL :: Select And Parse Json Data From 2 Columns Into Multiple Columns In A Table?

Apr 29, 2015

I have a business need to create a report by query data from a MS SQL 2008 database and display the result to the users on a web page. The report initially has 6 columns of data and 2 out of 6 have JSON data so the users request to have those 2 JSON columns parse into 15 additional columns (first JSON column has 8 key/value pairs and the second JSON column has 7 key/value pairs). Here what I have done so far:

I found a table value function (fnSplitJson2) from this link [URL]. Using this function I can parse a column of JSON data into a table. So when I use the function above against the first column (with JSON data) in my query (with CROSS APPLY) I got the right data back the but I got 8 additional rows of each of the row in my table. The reason for this side effect is because the function returned a table of 8 row (8 key/value pairs) for each json string data that it parsed.

1. First question: How do I modify my current query (see below) so that for each row in my table i got back one row with 19 columns.

SELECT A.ITEM1,A.ITEM2,A.ITEM3,A.ITEM4, B.*
FROM PRODUCT A
CROSS APPLY fnSplitJson2(A.ITEM5,NULL) B

If updated my query (see below) and call the function twice within the CROSS APPLY clause I got this error: "The multi-part identifier "A.ITEM6" could be be bound.

2. My second question: How to i get around this error?

SELECT A.ITEM1,A.ITEM2,A.ITEM3,A.ITEM4, B.*, C.*
FROM PRODUCT A
CROSS APPLY fnSplitJson2(A.ITEM5,NULL) B,  fnSplitJson2(A.ITEM6,NULL) C

I am using Microsoft SQL Server 2008 R2 version. Windows 7 desktop.

View 14 Replies View Related

Grouping On Data Change

Feb 13, 2012

I am trying to create a group on this data example

RecordNo, Item, Date,NULL
1, ABBB, NULL, 0 << first group
2, ABBB, 01-06-2011,NULL << first group
3, ABBB,NULL,NULL << 2nd group
4, ABBB, 02-01-2011,NULL << 2nd group
5,CAAA,NULL,NULL << 1st group
6,CAAA,NULL,NULL << 1st group
7,CAAA,01-01-2010,NULL << 1st group
8,CAAA,01-01-2011,NULL << 2nd group
9,CAAA,01-05-2012, NULL << 3rd group

Basically 3 groups on date, by item, so for each date change/ per part the group increments been playing with row_number partitions, but cant seem to get what i need.

View 14 Replies View Related

Grouping Dissimilar Data

Jan 16, 2007

I€™m trying to build a report that contains bank account activity. For 3 customers their activity is this:

Deposits
Date Amount
John 1/2/2007 500.00
1/7/2007 250.00

Mary 1/3/2007 100.00

Withdrawals
Date Amount
John 1/3/2007 100.00

Mary 1/2/2007 100.00
1/4/2007 200.00
1/6/2007 50.00

Sam 1/6/2007 50.00

I would like the report to have deposit/withdrawal info, with subtotals, grouped by customer, looking something like this:

Deposit Withdrawal
Cust Date Amount Date Amount
John 1/2/2007 500.00 1/3/2007 100.00
1/7/2007 250.00
750.00 100.00

Mary 1/3/2007 100.00 1/2/2007 100.00
1/4/2007 200.00
1/6/2007 50.00
100.00 350.00

Sam 1/6/2007 50.00
0 50.00

Because the deposit and withdrawal data is only related by customer, I€™ve broken it into 2 datasets.

I€™m totally stumped! Can someone get me going in the right direction on this?

Thanks

View 1 Replies View Related

Grouping Data Problem

Sep 25, 2006

Hello all

I am using SQL Server 2000. I have a table of over 1 million accounting transactions. I need to be able to remove all items that have contra items.

e.g

debit £100 - credit £100 - debit of £125 ( I only want to see the debit of £125)

I can achieve this in MS Access by grouping the key fields, suming the value fields and using the First() or Last() command for columns that I need to display but not group.

How can I achieve this in SQL?

All help appreciated.

View 4 Replies View Related

A Word About Meta-data, Pass Through Columns And Derived Columns

Oct 13, 2006

Here's another one of my bitchfest about stuff which annoy the *** out of me in SSIS (and no such problems in DTS):

Do you ever wonder how easy it was to set up text file to db transform in DTS - I had no problems at all. In SSIS - 1 spent half a day trying to figure out how to get proper column data types for text file - OF Course MS was brilliant enough to add "Suggest Types" feature to text file connection manager - BUT guess what - it sample ONLY 1000 rows - so I tried to change that number to 50000 and clicked ok - BUT ms changed it to 1000 without me noticing it - SO NO WONDER later on some of datatypes did not match. And boy what a fun it is to change the source columns after you have created a few transforms.

This s**hit just breaks... So a word about Derived Columns - pretty useful feature heh? ITs not f***ing useful if it DELETES SOME of the Code itself after there have been changes in dataflow. I cant say how pissed off im about that SSIS went ahead and deleted columns from flow & messed up derived columns just because the lineageIDs dont match.

Meta-data - it would be useful if you could change it and refresh it - im just sick and tired of it that it shows warnings and errors when there's nothing wrong - so after a change i need to doubleclick all my transforms so that those red & yellow boxes would disappear.

Oh and y I passionately dislike Derived columns - so you create new fields based on some data - you do some stuff - combine multiple columns to one, but you have no way saying remove the columns from the pipeline. Y you need it - well if you have 50K + rows with 30+ columns then its EXTRA useless memory overhead for your package.

Hopefully one day I will understand how SSIS works (not an ez task I say) - I might be able to spend more time on development and less time on my bitchfest - UNTIL then --> Another Day - Another Hassle with SSIS

View 5 Replies View Related

Need Help With A Simple Query - Grouping Data

Jul 30, 2007

Hello,

I have a table similar to the following (XYZ). I would like to write a select statement that will return the count of the unique items for each user that also happen to be less than 1 year old. The less than one year old part is rather easy dateadd(year, -1, getdate()), but I seem to be having a hard time figuring out how to get my desired result without using subselects. Any help greatly appreciated. Thanks in advance - Dan.

So my goal results are:

User Count
Dan 2
Dave 1


Table XYZ
ID User Item Value Date

1 Dan 1 20 5/5/2007

2 Dan 1 30 6/5/2007

3 Dave 2 25 6/1/2007

4 Dan 2 22 5/1/2007
5 Dan 3 23 5/1/2006



View 6 Replies View Related

Grouping Data In Consecutive Values

Oct 12, 2007

Hi Fellows
I am trying to organize these information.the data come form two tables that are not relating, but I did a join and my primary key is the filed polygon. I have a list of points(geomseq) for each polygon but the number of points(geomseq) can change. I have this inofrmation in a data base.

geomseq polygon xc yc x1 y2

0 17 21 22.5 0 0
3 17 21 22.5 40 40
2 17 21 22.5 0 20
4 17 21 22.5 20 0
1 17 21 22.5 0 10
5 17 21 22.5 10 10
1 18 40 40.5 0 20
4 18 40 40.5 20 30
0 18 40 40.5 0 0
3 18 40 40.5 10 20
2 18 40 40.5 5 15
5 18 40 40.5 30 35
6 18 40 40.5 40 40
9 18 40 40.5 80 80
7 18 40 40.5 45 45
8 18 40 40.5 50 60

I want something like this
geomseq polygon xc yc x1 y2

0 17 21 22.5 0 0
1 17 21 22.5 0 10
2 17 21 22.5 0 20
3 17 21 22.5 40 40
4 17 21 22.5 20 0
5 17 21 22.5 10 10
0 18 40 40.5 0 0
1 18 40 40.5 0 20
2 18 40 40.5 5 15
3 18 40 40.5 10 20
4 18 40 40.5 20 30
5 18 40 40.5 30 35
6 18 40 40.5 40 40
7 18 40 40.5 45 45
8 18 40 40.5 50 60
9 18 40 40.5 80 80



regards and thanks in advance
Edwin

View 3 Replies View Related

MDX Filtering And Grouping Data Within Subreports (help)

Aug 28, 2007

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.

View 1 Replies View Related

Grouping Data Flow Components

Nov 15, 2007

Hello everyone,

I am developing an SSIS solution where the Data Flow task extracts data from a source csv file, then performs several transformations on the source data and then starts inserting the cleansed data into several destination tables.

The Data Flow task is getting too large!

Question:
Is there a way (best practice) for grouping components in the Data Flow - similar to the Container concept in the Control Flow?

I know this question sounds too luxurious, but I really loose the overall picture, when the Data Flow canvas gets too crowded.

Thank you in advance.
Samar

View 7 Replies View Related

Transact SQL :: Grouping Data Within A DB Table?

Jul 9, 2015

I have a table with couple of hundred thousand records, i have added a new column to the table named MD_Group.

Now i need this column populated, so that every 10,000 row set in that table gets a numeric (incremental number) assigned starting from 1.

So the first 10,000 rows will have MD_Group = 1, next 10,000 rows will have MD_Group = 2 , next 10K MD_Group = 3 etc.

For testing purpose here is a results table with total of 11 rows where we want data grouped every 3 rows.

MD_Group
CustomerNumber
AmountBilled
1
12
15243
1
1231234
15243

[code]....

-- Create Sample Table

Declare @GroupRelation_Test TABLE (
MD_Group [varchar](20),
CustomerNumber [varchar](20) ,
AmountBilled [varchar](20) ,

[code]....

-- Test data

INSERT INTO @GroupRelation_Test
( CustomerNumber, AmountBilled,MinAmounttBilled)
SELECT'12','15243','' UNION ALL
SELECT'1231234','15243','' UNION ALL
SELECT'463','15243','' UNION ALL
SELECT'442','15243','' UNION ALL

[code]....

View 22 Replies View Related

Grouping Data Into Periods For Reporting

Aug 17, 2007

Hi there.

I am working on a set of reports where I am summing/averaging data elements based on what period they are in. For example, the report output should look something like this:









Period
Sum

May '07
41

April '07
14

Q2 '07
55

March '07
36

February '07
28

January '07
22

Q1 '07
86

June '07
N/A

YTD '07
141

December '06
33

November '06
27

October '06
42

Q4 '06
102

September '06
58

August '06
84

July '06
52

Q3 '06
194

June '06
40

May '06
41

April '06
14

Q2 '06
95

March '06
67

February '06
38

January '06
N/A

Q1 '06
105

YTD '06
496


For each of the items I am summing, all I have is a datetime of when the event happened. This is a relational database (not a cube), so I am struggling with how to create the 'buckets' based on period. I think the best way is to dynamically create the buckets based on a given date. Is there a way in RS that it can do this bucketing for you?

Thanks, Mike

View 4 Replies View Related







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