Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select query

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-11-29 : 05:58:02
Hi,
Can you let me know how to get to tblResult at the buttom from tblData
please?

tblData
Bid Ask Import_Date
NULL 113.4300 2007-11-29 07:01:00
113.3750 NULL 2007-11-29 07:01:00
NULL 113.4300 2007-11-29 07:03:00
113.3750 NULL 2007-11-29 07:03:00
NULL 113.4300 2007-11-29 07:05:00
113.3750 NULL 2007-11-29 07:05:00
NULL 113.4300 2007-11-29 07:07:00
...
...
...
...

tblResult
Bid Ask Import_Date
113.3750 113.4300 2007-11-29 07:01:00
113.3750 113.4300 2007-11-29 07:03:00
113.3750 113.4300 2007-11-29 07:05:00
NULL 113.4300 2007-11-29 07:07:00
...
...
...
...

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2007-11-29 : 06:19:38
Hi,

DECLARE @T TABLE (Bid VARCHAR(10), Ask VARCHAR(10), Import_Date DATETIME)

INSERT INTO @T
SELECT NULL, '113.4300', '2007-11-29 07:01:00' UNION ALL
SELECT '113.3750', NULL, '2007-11-29 07:01:00' UNION ALL
SELECT NULL, '113.4300', '2007-11-29 07:03:00' UNION ALL
SELECT '113.3750', NULL, '2007-11-29 07:03:00' UNION ALL
SELECT NULL, '113.4300', '2007-11-29 07:05:00' UNION ALL
SELECT '113.3750', NULL, '2007-11-29 07:05:00' UNION ALL
SELECT NULL, '113.4300', '2007-11-29 07:07:00'

--SELECT * FROM @T

SELECT MIN(BID) AS Bid, MIN(ASK) AS Ask, Import_Date
FROM @T
GROUP BY Import_Date
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-29 : 09:37:34
What's the difference between PeterNeo's and your query performance wise?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-11-29 : 11:11:07
Solved.
Thanks for your help
Go to Top of Page
   

- Advertisement -