How to return specific rows that meets certain conditions
I am totally new in SQL. I was working on a query that should return
specific rows only from a table. (see. example source table and desired
output below). can somebody help me figure out this one? I've tried
searching through related topics on iterating through rows but was
unsuccessful to find the answer I sought. thanks.
Sample table
Machine Station Defect Code CreateTime
1 LU f1 8/20/2013 7:07
1 LU f2 8/20/2013 7:07
1 SLC d1 8/20/2013 7:08
1 SLC d2 8/20/2013 7:09
1 SLC d3 8/20/2013 7:10
1 SLC d1 8/20/2013 7:10
1 SLC d2 8/20/2013 7:11
1 SLC d1 8/20/2013 7:17
1 SLC d1 8/20/2013 7:20
1 UL f3 8/20/2013 7:26
1 UL f4 8/20/2013 7:26
1 UL f3 8/20/2013 7:26
1 UL f4 8/20/2013 7:26
2 LU f2 8/20/2013 7:29
2 SLC d1 8/20/2013 7:31
2 SLC d1 8/20/2013 7:38
2 SLC d2 8/20/2013 7:38
2 SLC d3 8/20/2013 7:39
2 SLC d2 8/20/2013 7:39
2 SLC d4 8/20/2013 7:39
2 SLC d5 8/20/2013 7:42
2 SLC d1 8/20/2013 7:43
2 SLC d1 8/20/2013 7:52
2 SLC d1 8/20/2013 7:53
2 SLC d2 8/20/2013 7:53
2 SLC d2 8/20/2013 7:54
2 SLC d4 8/20/2013 7:55
2 SLC d5 8/20/2013 7:56
Needed result:
OCAP Triggered on Machine1. d1 multiple occurence
Machine Station Defect Code CreateTime
1 SLC d1 8/20/2013 7:08
1 SLC d1 8/20/2013 7:10
1 SLC d1 8/20/2013 7:17
1 SLC d1 8/20/2013 7:20
OCAP Triggered on Machine1. d1 consecutive occurence
Machine Station Defect Code CreateTime
1 SLC d1 8/20/2013 7:17
1 SLC d1 8/20/2013 7:20
OCAP Triggered on Machine 2. d1 consecutive occurence
Machine Station Defect Code CreateTime
2 SLC d1 8/20/2013 7:31
2 SLC d1 8/20/2013 7:38
OCAP Triggered on Machine 2. d2 multiple occurence
Machine Station Defect Code CreateTime
2 SLC d2 8/20/2013 7:38
2 SLC d2 8/20/2013 7:39
2 SLC d2 8/20/2013 7:53
No comments:
Post a Comment