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.
| Author |
Topic |
|
Adrian_m
Starting Member
4 Posts |
Posted - 2009-07-11 : 11:45:03
|
| Hi There,My first post, and so excited to see so much information available to help me refresh my skills in SQL. It used to be my day job about 10 years ago, and not touched it again until now, in a interest capacity mainly.Enough about me, onto my question....I have a table which is based on financial instruments. A row entry is made when there is an entry signal, another row for an exit signal, and a row in between these two rows for every day in between. The entry row has entry conditions - things like equity volatility etc. I'd like to be able to do a select on the exittrigger, but also be able to reference some of the entry criteria in the results, ie produce a query which shows every exit, as well as what the volatility was when the position was entered.Now my skills are so rusty, all I can do is select the exit row, ie:Select * from tradetablewhere exittrigger =1I think I need to do something like a nested select, but any pointers would be appreciated!Adrian |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-11 : 11:47:37
|
it would helps if you can provide your table structure, sample data and required result KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2009-07-11 : 13:22:03
|
| sounds like a case where you need to join the table multiple times:select * from table as t1 inner join table as t2 on ... inner joing table as t3.... |
 |
|
|
Adrian_m
Starting Member
4 Posts |
Posted - 2009-07-11 : 13:58:55
|
Maybe the following image may help. Would this need a join? Cheers,Adrian |
 |
|
|
Adrian_m
Starting Member
4 Posts |
Posted - 2009-07-11 : 15:26:42
|
| OK, I think I have worked it out. Joined the same table, removed the duplicates using the QTY purchased and QTY sold. Thanks for your help guys... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-12 : 03:31:55
|
| will there always be a single row each in table with entry and exit values 1? |
 |
|
|
|
|
|
|
|