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)
 For Peso,

Author  Topic 

ayamas
Aged Yak Warrior

552 Posts

Posted - 2007-11-21 : 07:58:04
Hi Peso the undisputed king of SQL ,

I would like to know whether this solution will work

DECLARE @Trans TABLE (TradeDate DATETIME, TransactionType VARCHAR(4), Quantity INT, Symbol VARCHAR(100), Amount MONEY)

INSERT @Trans
SELECT '1/1/2005', 'buy', 100, 'msft', 4000 UNION ALL
SELECT '2/1/2005', 'buy', 100, 'ge', 3000 UNION ALL
SELECT '3/1/2005', 'sell', 100, 'msft', 3000 UNION ALL
SELECT '4/1/2005', 'buy', 100, 'intc', 2200

select * from (select tradedate,symbol,transactiontype,row_number()over(partition by transactiontype order by tradedate
)as rowid from @trans)t1 where rowid<>1 and TradeDate<'5/1/2005'


for the solution you posted for the topic at

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

Regards.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-21 : 08:19:26
hmm.. i dare not post an answer... but why didn't you post this in the original thread?

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-11-21 : 08:22:34
Crazy idea ... maybe try it?

If your programming technique is to write some code, post it on a forum, and then ask people if it will work instead of simply trying it, you will not get far in this business I'm afraid ...

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-21 : 08:23:40
Why are we posting here ? I thought this is for Peso ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2007-11-21 : 08:26:24
No hard feelings guys,
Guys, I think the original thread is on the 55th page or something like that & it was posted about 3 months back.I accidently came across that post.
I just wanted to know whether my solution will work if the number of combinations and rows are more.
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2007-11-21 : 08:31:52
quote:
Originally posted by jsmith8858

Crazy idea ... maybe try it?

If your programming technique is to write some code, post it on a forum, and then ask people if it will work instead of simply trying it, you will not get far in this business I'm afraid ...

- Jeff
http://weblogs.sqlteam.com/JeffS





Yes Smith it is working for the sample data provided & also I have tried it.
I just was just looking for an opinion or suggestion from all you masters & gods of SQL.
Go to Top of Page
   

- Advertisement -