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 2000 Forums
 Transact-SQL (2000)
 request SQL Help

Author  Topic 

GrepZen
Starting Member

13 Posts

Posted - 2005-10-27 : 13:10:57
Here's a table that i'd like to get just the BidIDs with the earliest BidLastWinDate from.

CampaignID BidID BidAmount BidLastWinDate
----------- ----------- ----------- ---------------------------
11 54 200 2005-10-24 00:00:00.000
11 55 200 2005-10-01 00:00:01.000
11 56 200 2005-10-01 00:00:01.000
12 57 110 2005-10-01 00:00:01.000
13 58 250 2005-10-17 00:00:00.000
13 59 250 2005-10-31 00:00:00.000
13 60 250 2005-10-30 00:00:00.000
13 61 250 2005-10-19 00:00:00.000
13 62 250 2005-10-01 00:00:01.000
16 72 110 2005-10-18 00:00:00.000
17 73 130 2005-12-26 00:00:00.000
28 99 180 2005-10-24 00:00:00.000
42 97 130 2005-10-01 00:00:16.000
45 103 210 2005-10-01 00:00:10.000
45 113 220 1900-01-01 00:01:55.000
45 115 320 1900-01-01 00:01:55.000
45 104 120 2005-10-01 00:01:20.000
47 102 200 2005-10-01 00:00:19.000
49 109 100 2005-10-01 00:00:12.000

SELECT CampaignID, MIN(BidLastWinDate)as BLWD
FROM VIEW_ValidBids
GROUP BY CampaignID

gets me:

CampaignID BLWD
----------- ---------------------------
11 2005-10-01 00:00:01.000
12 2005-10-01 00:00:01.000
13 2005-10-01 00:00:01.000
16 2005-10-18 00:00:00.000
17 2005-12-26 00:00:00.000
28 2005-10-24 00:00:00.000
42 2005-10-01 00:00:16.000
45 1900-01-01 00:01:55.000
47 2005-10-01 00:00:19.000
49 2005-10-01 00:00:12.000


.. but I can't seem to get the BidID's into this list AND keep just the min(BidLastWinDate)

can anyone lend me a hand?










Micke

X002548
Not Just a Number

15586 Posts

Posted - 2005-10-27 : 13:14:38
That's just like this one...what about ties?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=57036



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

GrepZen
Starting Member

13 Posts

Posted - 2005-10-27 : 13:31:49
That is somewhat similar yes, perhaps the answer for one could be applied to the other.

In my case, there will never be any ties.

Micke
Go to Top of Page
   

- Advertisement -