January 15, 2015 at 12:46 pm
I have table called Tracking_changes which contain 5 columns and 5th column as getdate
I want to get the output ONLY with differences in other column 3 and 4 and getdate with group by
We enter data on daily basis and getdate will capture the data for given date so I need Output for any changes on other column with group by getdate.
Nita
January 15, 2015 at 12:57 pm
I got confused with your explanation. Could you post DDL and sample data (as insert statements) along with expected results based on that sample data?
That will give you better and faster answers.
January 15, 2015 at 1:03 pm
This is the Data I have in my table
NameIDGradesecSystem Date
sac11A1/5/2012
paul21A1/5/2012
Simon32B1/5/2012
Kelly42B1/5/2012
Nimo52B1/5/2012
sac11A1/4/2013
paul22A1/4/2013
Simon32B1/4/2013
Kelly42B1/4/2013
Nimo53C1/4/2013
OUTPUT I am expecting below (since only Grade and Sec I am concern about from System Date change)
NameIDGradesecSystem Date
sac11A1/4/2013
Nimo53C1/4/2013
January 15, 2015 at 1:06 pm
Let me give with Example:
I have table called Tracking_changes which contain 4 columns a
I want to get the output ONLY with differences in other column 2 and 3 and System Date with group by
In Tracking_Changes I have data with
NameIDGradesecSystem Date
sac11A1/5/2012
paul21A1/5/2012
Simon32B1/5/2012
Kelly42B1/5/2012
Nimo52B1/5/2012
sac11A1/4/2013
paul22A1/4/2013
Simon32B1/4/2013
Kelly42B1/4/2013
Nimo53C1/4/2013
I am expecting OUTPUT with grade changes and Sec ONLY on the same table
NameIDGradesecSystem Date
sac11A1/4/2013
Nimo53C1/4/2013
January 15, 2015 at 1:55 pm
It's still not clear what you're trying to get at here. What do you mean differences in column 2 and 3? Are you referring to the columns Grade and Sec? It would be clearer if you call them by their names. And what do you mean by difference? Are you trying to compare these rows over time? To eachother? What is the criteria for rows not being returned, vs being returned?
January 15, 2015 at 8:46 pm
Nita Reddy (1/15/2015)
Let me give with Example:I have table called Tracking_changes which contain 4 columns a
I want to get the output ONLY with differences in other column 2 and 3 and System Date with group by
In Tracking_Changes I have data with
NameIDGradesecSystem Date
sac11A1/5/2012
paul21A1/5/2012
Simon32B1/5/2012
Kelly42B1/5/2012
Nimo52B1/5/2012
sac11A1/4/2013
paul22A1/4/2013
Simon32B1/4/2013
Kelly42B1/4/2013
Nimo53C1/4/2013
I am expecting OUTPUT with grade changes and Sec ONLY on the same table
NameIDGradesecSystem Date
sac11A1/4/2013
Nimo53C1/4/2013
For sac above, there are no such changes so I don't understand why it's included in your example output.
For Paul, there are changes and don't understand why it's not included in your example output.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 16, 2015 at 1:06 am
Just to help restate the task in more formal way let's start with this (not tested due to lack of DDL and sample data script)
-- Date interval params
declare @sd date ='20130101';
declare @ed date ='20150101';
-- get a set of (Name, ID)s which have any changes in Grade or sec
-- over the interval
select Name, ID
from Tracking_changes
where Systemdate between @sd and @ed
group by Name, ID
having max(Grade) <> min(Grade) or max(sec) <> min(sec);
Is it a step in right direction?
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply