Compare Consecutive Rows in a table
Hi,
I want to compare consecutive rows for each employee. I need to compare SchedulEnd column of the first row with the ScheduleStart of the second row as so on. if both the values are same then i need to generate a sequence like 00 for the first record 01 for
the second record and so on. if the time is not same the the sequence should start with 00.
Example: lets say the data is like:
schedule start
schedule end
10
11
11
12
12
13
15
18
the output should be like
sequence
00
01
02
00
Thank you very much for the quick reply.
I have one more scenario now, with the same data, i want the output like this
<table>
<tr>
<th>Employee</th>
<th>Schedule Time</th>
<th>sequence</th>
<th>Remarks</th>
</tr>
<tr>
<td>1</td>
<td>10</td>
<td>00</td>
<td>sequence "00" as schedule time is unique, 10 is the schedule start time</td>
</tr>
<tr>
<td>1</td>
<td>11</td>
<td>00</td>
<td>sequence "00" as schedule time is unique, 11 is the schedule end time for the first record</td>
</tr>
<tr>
<td>1</td>
<td>11</td>
<td>01</td>
<td>sequence "01" as schedule time is unique, 11 is the schedule start time of the next record</td>
</tr>
<tr>
<td>1</td>
<td>12</td>
<td>00</td>
<td>sequence "00" as schedule time is unique, 12 is the schedule end time of the previous record</td>
</tr>
<tr>
<td>1</td>
<td>12</td>
<td>01</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
Similar Messages
-
How to compare two rows from two table with different data
how to compare two rows from two table with different data
e.g.
Table 1
ID DESC
1 aaa
2 bbb
3 ccc
Table 2
ID DESC
1 aaa
2 xxx
3 ccc
Result
2Create
table tab1(ID
int ,DE char(10))
Create
table tab2(ID
int ,DE char(10))
Insert
into tab1 Values
(1,'aaa')
Insert
into tab1 Values
(2,'bbb')
Insert
into tab1 Values(3,'ccc')
Insert
into tab1 Values(4,'dfe')
Insert
into tab2 Values
(1,'aaa')
Insert
into tab2 Values
(2,'xx')
Insert
into tab2 Values(3,'ccc')
Insert
into tab2 Values(6,'wdr')
SELECT
tab1.ID,tab2.ID
As T2 from tab1
FULL
join tab2 on tab1.ID
= tab2.ID
WHERE
BINARY_CHECKSUM(tab1.ID,tab1.DE)
<> BINARY_CHECKSUM(tab2.ID,tab2.DE)
OR tab1.ID
IS NULL
OR
tab2.ID IS
NULL
ID column considered as a primary Key
Apart from different record,Above query populate missing record in both tables.
Result Set
ID ID
2 2
4 NULL
NULL 6
ganeshk -
Merging consecutive rows of a table
I want to merge consecutive rows of a table. i.e. if my table has 4 rows of data then my ouput of query will have only 3 rows because
rows 1 and 2 are merged to first row of result
rows 2 and 3 are merged to second row of result
rows 3 and 4 are merged to third row of result
For example if my table is
A | B
1 | 4
9 | 7
3 | 2
7 | 9
then output of query should be
A | B |A1| B1
1 | 4 | 9 | 7
9 | 7 | 3 | 2
3 | 2 | 7 | 9
How can i write a query to achieve this?If SortKey is B and we use DB2 or SQLServer2005,
we can emulate Lag and Lead.
for instance
create table LagLeadTable as
select 'AAAA' as Code,100 as SortKey,5 as Val from dual
union select 'AAAA',200,20 from dual
union select 'AAAA',300,15 from dual
union select 'AAAA',400,30 from dual
union select 'BBBB',500,60 from dual
union select 'BBBB',600,70 from dual
union select 'BBBB',610,90 from dual
union select 'BBBB',620,50 from dual
union select 'BBBB',630,70 from dual
union select 'CCCC',100,80 from dual;
select Code,SortKey,
Lag(Val,3,0) over(partition by Code order by SortKey) as Lag3,
Lag(Val,2,0) over(partition by Code order by SortKey) as Lag2,
Lag(Val,1,0) over(partition by Code order by SortKey) as Lag1,
Val,
Lead(Val,1,0) over(partition by Code order by SortKey) as Lead1,
Lead(Val,2,0) over(partition by Code order by SortKey) as Lead2,
Lead(Val,3,0) over(partition by Code order by SortKey) as Lead3
from LagLeadTable;Above query can be emulated by below query.
select Code,sortkey,
coalesce(max(Val) over(partition by Code order by SortKey
Rows between 3 preceding and 3 preceding),0) as Lag3,
coalesce(max(Val) over(partition by Code order by SortKey
Rows between 2 preceding and 2 preceding),0) as Lag2,
coalesce(max(Val) over(partition by Code order by SortKey
Rows between 1 preceding and 1 preceding),0) as Lag1,
Val,
coalesce(max(Val) over(partition by Code order by SortKey
Rows between 1 following and 1 following),0) as Lead1,
coalesce(max(Val) over(partition by Code order by SortKey
Rows between 2 following and 2 following),0) as Lead2,
coalesce(max(Val) over(partition by Code order by SortKey
Rows between 3 following and 3 following),0) as Lead3
from LagLeadTable;my site :-)
http://www.geocities.jp/oraclesqlpuzzle/8-13.html -
Compare two rows in same table
Hi,
I want to compare two rows (some columns) in the same table, and if the data in the data columns is different, I want to pick the latest one. The table is date tracked. For instance I have an address table with different addresses for an employee with effective date. I want to be able to pick the latest row if the postal code is different for the 2 rows. Is this possible in sql. I can do this in Pl/sql, but dont want to use it. Eg
address_id, postal_code, person_id,last_update_date
123, pn123,1,12-JAN-01
124,pu124,1,13-JAN-01
I want to be able to retrieve just the second line.
Any help is appreciatedWelcome to the forum!
Whenever you post please provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
>
The table is date tracked. For instance I have an address table with different addresses for an employee with effective date. I want to be able to pick the latest row if the postal code is different for the 2 rows.
>
Your question is a little confusing because you are using terms like 'date tracked' and 'effective date' without explaining exactly what your definitions of those terms is.
Why do you want the latest record ONLY if the postal code is different? What if the address is different? Then which record do you want?
Why not just take the record for each person/company that has the latest date? If the data is the same then it doesn't which record you get so the one with the latest date will do. And if the data is different taking the one with the latest date gives you the latest data.
The classic definition of effective date is 'the date the information becomes effective'. Information with a given effective date is NOT in effect before that date and is SUPERCEDED when data is entered with a later effective date if the actual date is later than or equal to the effective date. Using your data
>
123, pn123,1,12-JAN-01
124,pu124,1,13-JAN-01
>
The first record IS NOT effective for dates prior to 12-JAN-01. In fact for a query looking for data prior to that date there isn't any data.
The first record is also NOT effective for dates on or after 13-JAN-01. Only the second record is effective.
If you added a record for 14-JAN-01 this record would not be effective until on or after that date (i.e. not for another 4 1/2 months).
So for the classic definition of effective date the query needs to provide the AS OF date to use to obtain the data. If, as in your system, you are not allowed to create records with dates in the future and you just want the latest record then you can just select the record with the MAX(myDate) value for the given person_id, address_id or whatever your key values are.
Edited by: rp0428 on Aug 11, 2012 7:50 AM -
Grouping to be done by comparing 2 rows in a table
Hi
I'm using oracle 10g.
I have a table with 3 columns
id--------origin--------destination
1---------N1-----------N3
2---------N2-----------N4
3---------N2-----------N4
4---------N1-----------N3
5---------N2-----------N6
6---------N1-----------N3
7---------N2-----------N6
if there are common id's contains the same origin and same destination then we need to group it like
id--------origin--------destination
1---------N1-----------N3-----G1
2---------N2-----------N4-----G2
3---------N2-----------N4-----G2
4---------N1-----------N3-----G1
5---------N2-----------N6-----G3
6---------N1-----------N3-----G1
7---------N2-----------N6-----G3
please help me
thanks
sandeepHi,
Whenever you have a problem, please post CREATE TABLE and INSERT statements for the sample data. You'll get better answers sooner.
What role (if any) does main_group play in this problem? Should all the rows with the same new group also have the same main_group? If so:
WITH got_group_flag AS
SELECT main_group, id, start_date, end_date
, CASE
WHEN start_date <= MAX (end_date) OVER ( PARTITION BY main_group
ORDER BY start_date
, id
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
THEN 0
ELSE 1
END AS group_flag
FROM table_x
-- WHERE ... -- If you need any filtering, do it here
SELECT main_group, id, start_date, end_date
, 'G' || SUM (group_flag) OVER ( ORDER BY main_group
, start_date
, id
) AS new_group
FROM got_group_flag
ORDER BY main_group
, start_date
;As you can see, GROUP_FLAG = 1 if a new_group starts with the current row, when sorted by start_date and id. If start_date is not unique, then we need something like id in the ordering, to make sure that the order in SUM (in the main query) will be the same as the order used in MAX (in the sub-query).
Once we know where the new_groups start, finding to which new_group each row belongs is just a matter of adding up all the starting points so far.
If main_group is not a factor in determining the new_group, then omit references to main_group in both analytic clauses.
This assumes that id is unique, and that start_date <= end_date on each row.
This does NOT assume anything else about the dates, e.g., that start_date or end_date is unique, or that, if row A has an earlier start_date than row B, then A will have an earlier end_date, too.
Edited by: Frank Kulash on Feb 15, 2011 2:23 PM
Added explanation. -
Compare a row in a table with the prevoius row
How i can compare in a page jspx, the actual row with the prevoius?
Thank you very much.comparing
-
Taking the difference between two consecutive rows of a table
My table structure with value is as follows:
time parameter value
16:00 STS 10
17:00 STS 20
18:00 STS 45
Now with a single select query I want to retreive the value as follows :
time_difference para_value_difference
1 10 (difference between 20 and 10)
1 25 (difference between 45 and 20))
is it possible ? if yes then plz give me the answer ....its urgent.....SQL> create table mytable
2 as
3 select to_date('16:00','hh24:mi') time, 'STS' parameter, 10 value from dual union all
4 select to_date('17:00','hh24:mi'), 'STS', 20 from dual union all
5 select to_date('18:00','hh24:mi'), 'STS', 45 from dual
6 /
Tabel is aangemaakt.
SQL> select (time - prev_time) * 24 time_difference_in_hours
2 , value - prev_value value_difference
3 from ( select t.*
4 , lag(value) over (order by time) prev_value
5 , lag(time) over (order by time) prev_time
6 from mytable t
7 )
8 where prev_time is not null
9 /
TIME_DIFFERENCE_IN_HOURS VALUE_DIFFERENCE
1 10
1 25
2 rijen zijn geselecteerd.Regards,
Rob. -
Table compare deleting rows which does not exist in target table
Hi Gurus,
I am struggling with an issue in Data Services.
I have a job which uses Table Compare, then History Preserving and then a Key Generation transforms.
There is every possibility that data would get deleted from the source table.
Now, I want to delete them from the target table also.
I tried Detect deleted rows but it is not working.
Could some one please help me on this issue.
Thanks,
Raviteja.Doesn't history preserving really only operate on "Update" rows. Wouldn't it only process the deletes if you turned the "Preserve Delete row(s) as update row(s)" on?
I would think if you turned on Detect Delete rows in the Table compare and did not turn this on in the history preserving it would retain those rows as delete rows and effectively remove them from the target.
Preserve delete row(s) as update row(s)
Converts DELETE rows to UPDATE rows in the target warehouse and, if you previously set effective date values (Valid from and Valid to), sets the Valid To value to the execution date. Use this option to maintain slowly changing dimensions by feeding a complete data set first through the Table Comparison transform with its Detect deleted row(s) from comparison table
option selected. -
Compare two rows in a same table
Dear all
I need to compare two rows in the same table, I dont know hoe to do it in pl/sql. Some one please help me on this.
example:
tr br price
xya0001 ama7 12
xya0003 ama6 14
xya0004 ama7 16
in the table tr is a unique value for each row, I need to compare price column and see whether the first value is less or greater than the next value and, if it is greater put the corresponding br value to a variable and if it is smaller put the corresponding br value to another variable. I dont know a method to do it, as I'm new to pl/sql. Some one please help me in thisnot sure what you intend to do as you have mentioned that "TR" is unique and you just want to compare each record with just the next record. Hope below query helps. The value "G" or "L" in flag would indicate if the current records price is greater than or less than the price in next record.
select tr,br,price,col4, case when price> col4 then 'G' when price< col4 then 'L' end flag from (
select tr,br,price,lag(price,1,0) over(order by tr) col4 from testcomp
) -
PL/SQL-find out extra rows present in table by comparing 2 similar tables
Hi, can any one give me an idea to find out the extra rows present in table by comparing 2 similar tables using pl/sql.
REQUIREMENT::i am working on the upgrade environment.my previous database has some tables and having data.Now functional folks are adding some new data to the existing tables for the upgrade database.I need to identify that new rows which are added by them.
for this , i created name table with 2 columns n,n1 which contains the table names.
Table Name:Name
columns:n n1
a ax
b bx
c cx
a,b c........are the table names which are in the previous database environment.(approx >1500 tables)These tables having data.
ax,bx,cx..........table names which are in the upgrade environment contains the extra data which is added by the functional folks.
a&ax,b&bx.................(approx 1500 tables) are having same structure except some of them.
Now i want to write a pl/sql program that reads both table names a&ax from name table and then by comparing the rows of a&ax ,i need to find out the extra rows present in the ax table to store that in different place.
Example:
a table
id name
1 co
2 wi
3 il
ax table
id name
1 co
2 wi
3 il
4 va
5 ca
Here i need to find out the difference b/n the 2 tables ,the extra rows id 4,5 and place it some where.this is just for demo, is this you mean?
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e full outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7934 MILLER 10 10 ACCOUNTING
7839 KING 10 10 ACCOUNTING
7782 CLARK 10 10 ACCOUNTING
snipp........
7521 WARD 30 30 SALES
7499 ALLEN 30 30 SALES
156 1
12 1
40 OPERATIONS
90 LOGISTIC
18 rows selected.
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e left outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7934 MILLER 10 10 ACCOUNTING
7839 KING 10 10 ACCOUNTING
7782 CLARK 10 10 ACCOUNTING
7902 FORD 20 20 RESEARCH
snipp..................
7654 MARTIN 30 30 SALES
7521 WARD 30 30 SALES
7499 ALLEN 30 30 SALES
156 1
12 1
16 rows selected.
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e[b] right outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7369 SMITH 20 20 RESEARCH
7499 ALLEN 30 30 SALES
7521 WARD 30 30 SALES
7566 JONES 20 20 RESEARCH
snipp......................
7902 FORD 20 20 RESEARCH
7934 MILLER 10 10 ACCOUNTING
40 OPERATIONS
90 LOGISTIC
16 rows selected. -
Can't compare a row with other rows within a table.. (many to many compare)
Hi all..
I am very new to PL/SQL..
I need to travers through a table for comparing it's rows with in the table with other rows. For this I am trying to use bellow Pl/sql.
create or replace compare()
Declare
VAR_HIT CHAR(1);
SEARCH_RECORD_DATA UDB.table1%ROWTYPE;
CANDIDATE_RECORD_DATA UDB.table1%ROWTYPE;
CURSOR SEARCH_RECORDS_CURSOR IS SELECT * FROM UDB.table1 order by registration_id;
CURSOR CANDIDATE_RECORDS_CURSOR IS SELECT * FROM UDB.table1 order by registration_id;
BEGIN
FOR SEARCH_RECORD_DATA IN SEARCH_RECORDS_CURSOR LOOP
FOR CANDIDATE_RECORD_DATA IN CANDIDATE_RECORDS_CURSOR LOOP
IF (CANDIDATE_RECORD_DATA.DECISION='P') THEN
VAR_HIT:='y';
IF(CANDIDATE_RECORD_DATA.FIRST_NAME!='unknown') AND (CANDIDATE_RECORD_DATA.FIRST_NAME!=SEARCH_RECORD_DATA.FIRST_NAME) THEN
VAR_HIT:='n';
ELSIF(CANDIDATE_RECORD_DATA.LAST_NAME!='unknown') AND (CANDIDATE_RECORD_DATA.LAST_NAME!=SEARCH_RECORD_DATA.LAST_NAME) THEN
VAR_HIT:='n';
ELSIF(CANDIDATE_RECORD_DATA.BIRTH_DATE!='unknown') AND (CANDIDATE_RECORD_DATA.BIRTH_DATE!=SEARCH_RECORD_DATA.BIRTH_DATE) THEN
VAR_HIT:='n';
ELSIF(CANDIDATE_RECORD_DATA.GENDER!='U') AND (CANDIDATE_RECORD_DATA.GENDER!=SEARCH_RECORD_DATA.GENDER) THEN
VAR_HIT:='n';
ELSIF(CANDIDATE_RECORD_DATA.FATHER_NAME!='unknown') AND (CANDIDATE_RECORD_DATA.FATHER_NAME!=SEARCH_RECORD_DATA.FATHER_NAME) THEN
VAR_HIT:='n';
ELSIF (CANDIDATE_RECORD_DATA.MOTHER_NAME!='unknown') AND (CANDIDATE_RECORD_DATA.MOTHER_NAME!=SEARCH_RECORD_DATA.MOTHER_NAME) THEN
VAR_HIT:='n';
END IF;
IF(VAR_HIT='y') THEN
INSERT INTO UDB.BIO_DI_HIT_RESULT(REGISTRATION_ID,SEARCH_ID,HIT_CANDIDATE_ID,SEARCH_DETAILS,CANDIDATE_DETAILS) VALUES (SEARCH_RECORD_DATA.REGISTRATION_ID,SEARCH_RECORD_DATA.EGM_NO,CANDIDATE_RECORD_DATA.EGM_NO,VAR_SEARCH_DETAILS,VAR_CANDIDATE_DETAILS);
UPDATE UDB.BIO_RECORDS_DEMOGRAPHICS SET DECISION='D';
END IF;
END IF;
END LOOP;
commit;
END LOOP;
END;
Outer loop is working fine (it is raversing throughout the table) (say for 8000 records 8000 times)
But Enner loop is not working fine e.i. it's running just for 8000 times for 8000 records. while it should run more then 8000 time..
Can any one help me..
Is the way of using two cursor on one table for comparing each row of record is correct????????? :(Finally I come up with this:
INSERT INTO UDB.BIO_DI_HIT_RESULT(REGISTRATION_ID,SEARCH_ID,HIT_CANDIDATE_ID,SEARCH_DETAILS,CANDIDATE_DETAILS)
SELECT SEARCH.REGISTRATION_ID, SEARCH.Key_NO,CANDIDATE.Key_NO,
'First name='||SEARCH.FIRST_NAME||',Last name='||SEARCH.LAST_NAME||',Birth date='||SEARCH.BIRTH_DATE||',Gender='||SEARCH.GENDER||',Fathers name='||SEARCH.FATHER_NAME||',Mother name='||SEARCH.MOTHER_NAME,
'First name='||CANDIDATE.FIRST_NAME||',Last name='||CANDIDATE.LAST_NAME||',Birth date='||CANDIDATE.BIRTH_DATE||',Gender='||CANDIDATE.GENDER||',Fathers name='||CANDIDATE.FATHER_NAME||',Mother name='||CANDIDATE.MOTHER_NAME
FROM UDB.BIO_RECORDS_DEMOGRAPHICS SEARCH,UDB.BIO_RECORDS_DEMOGRAPHICS CANDIDATE
WHERE (SEARCH.FIRST_NAME!='unknown' OR SEARCH.LAST_NAME!='unknown' OR SEARCH.BIRTH_DATE!='unknown' OR SEARCH.GENDER!='unknown' OR SEARCH.FATHER_NAME!='unknown' OR SEARCH.MOTHER_NAME!='unknown')
AND SEARCH.REGISTRATION_ID != CANDIDATE.REGISTRATION_ID
AND SEARCH.REGISTRATION_ID < CANDIDATE.REGISTRATION_ID
AND (SEARCH.FIRST_NAME='unknown' OR CANDIDATE.FIRST_NAME IN (SEARCH.FIRST_NAME,'unknown'))
AND (SEARCH.LAST_NAME='unknown' OR CANDIDATE.LAST_NAME IN (SEARCH.LAST_NAME,'unknown'))
AND (SEARCH.BIRTH_DATE='unknown' OR CANDIDATE.BIRTH_DATE IN (SEARCH.BIRTH_DATE,'unknown'))
AND (SEARCH.GENDER='U' OR CANDIDATE.GENDER IN (SEARCH.GENDER,'U'))
AND (SEARCH.BIRTH_DATE='unknown' OR CANDIDATE.BIRTH_DATE IN (SEARCH.BIRTH_DATE,'unknown'))
AND (SEARCH.FATHER_NAME='unknown'OR CANDIDATE.FATHER_NAME IN (SEARCH.FATHER_NAME,'unknown'))
AND (SEARCH.MOTHER_NAME='unknown' OR CANDIDATE.MOTHER_NAME IN (CANDIDATE.MOTHER_NAME,'unknown'))
ORDER BY SEARCH.REGISTRATION_ID;
Now it realy meet all my final table requirement.. I am happy.. :)
But again last requirement is like..
In the final BIO_DI_HIT_RESULT table I need to add one more column named as match_count
This column will have values of total no. of exact match field (not unknown) for each records in the BIO_DI_HIT_RESULT.....
One way of duing this is--
Step1: I will use a cursor for traversing through each of the rows in BIO_DI_HIT_RESULT.
Step 2: And based on count of matches in search_details(substring) and candiate_details(substring) I update each and every rows of the table.
It will be very slow.. And for records like 2 million records.. I can't think of this idea. :(
Sooooo,, Is there ANY BETTER WAY OF DOING THIS AS WELL.. BETTER MEANS FAST WAY.. :(
Thanks in advance....
Edited by: user13367608 on Jan 8, 2011 2:13 AM -
Comparing values in two consecutive rows?
Hello.
Can I compare the value of the same field in two consecutive rows?
If it is. How could I do it?
Thanks in advanceHi,
You can use analytics like LAG/LEAD, but it would be helpful if you'd post an example.
Search and read the docs for examples @ http://tahiti.oracle.com
A search on this forum will give you some examples as well. -
Calculate date differences in consecutive rows and generate a sequence
Hi Guys,
I am trying to implement one scenario where in i need to compare the date differences for consecutive rows and generate a sequence against that.
this is the table schema:
create table temp
id int identity(1,1),
emp_id int,
time datetime
insert into temp
values
(1, '2011-02-20 12:30:00.000'),
(1, '2011-02-20 12:32:34.172'),
(1, '2011-02-20 12:32:34.172'),
(1, '2011-02-20 12:43:21.004'),
(1, '2011-02-20 12:46:39.745'),
(2, '2011-02-20 12:48:06.004'),
(2, '2011-02-20 12:48:06.004'),
(2, '2011-02-20 12:53:07.733'),
(2, '2011-02-20 12:55:30.295');
now, I want to compare the first date-time with the second and so on. now if the date-time difference is same for two consecutive rows then the sequence should increment by 1 otherwise the sequence again will start from '00' for any unique date-time.
This sequence number should start from '00' from each employee.
I want the output to be like this
ID emp_id
time
sequence
1 1 2011-02-20 12:30:00.000
00
2 1 2011-02-20 12:32:34.172
00
3 1 2011-02-20 12:32:34.172
01
4 1 2011-02-20 12:32:34.172
02
5 1 2011-02-20 12:46:39.745
00
6 2
2011-02-20 12:48:06.004 00
7 2
2011-02-20 12:48:07.003 00
8 2
2011-02-20 12:48:07.003 01
9 2
2011-02-20 12:46:39.745 00
Please revert as soon as possible as this is a bit urgent.
Thank You in Advance. :)create table temp
(id int identity(1,1),
emp_id int,
time datetime
insert into temp values
(1, '20110220 12:30:00.000'),
(1, '20110220 12:32:34.172'),
(1, '20110220 12:32:34.172'),
(1, '20110220 12:43:21.004'),
(1, '20110220 12:46:39.745'),
(2, '20110220 12:48:06.004'),
(2, '20110220 12:48:06.004'),
(2, '20110220 12:53:07.733'),
(2, '20110220 12:55:30.295');
go
SELECT id, emp_id, time,
dateadd(mcs, (row_number() OVER(PARTITION BY emp_id, time ORDER BY
id) - 1) * 10,
convert(datetime2(5), time)) AS [Sequence]
FROM temp
ORDER BY id
go
DROP TABLE temp
Erland Sommarskog, SQL Server MVP, [email protected] -
Reading the Data from dynamically added rows of a table...
Hi,
I am using adobe interactive form (WD ABAP) in which i am adding the table rows dynamically (using Jscript code). I have to fech these data into an internal table. But I can read only the first row data..
Also While adding rows dynamically the same data is repeating for the consecutive rows..
I have found many similar posts in sdn, but i cannot get the solution. They have mentioned about adding in WDDOINIT method. Can anyone explain me what should be done,..?
1) How to solve repeatative data while adding rows..?
2) How to read dynamically added row data during runtime into internal table..?
Thanks,
Surya.Discussed @ SDN lot of time before. Have a look at any of below threads:-
Dynamic table in interactive form...
Make dynamic tables in Adobe Interactive forms
Adding Rows dynamically upon clicking the button
How to get values to WebDynpro ABAP from dynamic table?
Chintan -
Compare two columns between two tables
Hi all,
I have two separate datasets in Table 1 and Table 2.
Both datasets have Column A First name and Column B Last name in common.
The data in the subsequent columns is different.
Some of the people listed in each table are the same.
I want to delete the people from Table 1 who are in table 2.
If I run a formula like this =COUNTIF(Table 1 :: A2:A200, A2) I can return a 1 or 0, use conditional formatting to colour that cell, sort the table and delete all the rows containing 1.
However that only checks for First Name.
What I need to do is check if First name AND Last name in Table 1 are the same as First Name AND Last Name in Table 2 - and then return a True of False (1 or 0 or anything) in a separate column.
Please help.
Thanks in advance.
M.Moich wrote:
Presumably this lets me compare multiple values across multiple tables also?
Moich,
As you will see as you become familiar with this function, it can only count rows in one table. The comparison (criteria) values can come from anywhere, but what you are counting are "records" that meet the multiple criteria. A record is one row. I think that was your question, but I'm not positive.
I can't seem to find how to insert formulas into the conditional rules.
You'll have to put the formulas elsewhere and refer to them with simple comparisons.
Jerry
Maybe you are looking for
-
Bridge CS3 won't open on school network
HI all, Our school runs Win XP, uses Novell, and has CS3 installed in our business labs. As an administrator on the network, I have no problem at all opening Bridge. As a student though, Adobe Bridge will not open. I've tried on systems with original
-
Control FLV playback with button on different timeline
I have an FLVPlayback instance on my stage within a movie clip within a movie clip eg. _root.showreel_mc.showreelHolder.showreel (where showreel is the instance name given to the FLV component itself) I already have a button that fades out showreel_m
-
Hi all, If I connect a regular Apple Universal Dock to the ATV's USB port (in order to charge my iPod Touch): - Will the Dock receive power ? - Will inserting the Touch for charging interfere in any way with the ATV or vice versa ? Thanks for your in
-
Kwin crash after the last update, KDE unstable !!!
after the last update, this is the error http://i43.tinypic.com/27z9lr8.png http://i42.tinypic.com/96di52.png then there are the kde packages have been updated. kde-base-artwork kde-l10n-it kde-wallpapers kdebase-dolphin kdebase-katepart kdebase-kdep
-
My E65 pairs with the Bluetooth in my Nissan X-trail, and dials using voice dial, (although no sound of the dialing is heard). When the call is answered, the connection is dropped, although the phone is still paired. I have deleted the pairing and re