By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,842 Members | 2,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,842 IT Pros & Developers. It's quick & easy.

merging rows for the same time stamp

P: 26
Hi,
My question is about retrieving single records based on a time column, i mean the result set should not include duplicate rows for a unique time value as an example:

A B C D Time
-------------------------------------------------------------
x x x x 1
y y y y 1
z z z z 2

should return either.
{x x x x x 1, z z z z z 2} or {y y y y y 1, z z z z z 2}
The selection of the row for the same time is not important

Actually i want this statement to be executed based on two parameters: one the number of rows to be returned, second the time value that Time column should have a greater value than. The statement should be capable of returning a specific number of rows with a Time value greater than a specific time

In the second case, i need a more complex query that shoul extract one exact row from multiple rows for the same time. Here is the example table:

A B C D id Time
------------------------------------------------------------------------
x NULL x NULL 1 1
NULL y NULL y 1 1
z NULL z NULL 1 1
NULL w NULL w 1 1
x NULL x NULL 2 1
NULL y NULL y 2 1

Here i want a complete record for each id at specific time. sample resultsets are as follows:
{x y x y 1 1, x y x y 2 1} or
{z w z w 1 1, x y x y 2 1} . again the merging strategy is not important, but this statement should also be capable of returning a specific number of rows with a Time value greater than a specific time

Thanks
Sep 4 '09 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
You might want to check if you can PIVOT/UNPIVOT your table.

Happy Coding!!!

--- CK
Sep 5 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.