Tough SQL problem for an amateur like me -


my family has several stock accounts, , keep table of stock values contents , enter current values daily. fields are...

  account / ticker / quantity / closingdate/  closing (current price) 

to report of current stock contents , recent price, using code. add row row, , account total (for account # 2, example ). table designed way can track individual stock performance.

select distinct ticker, account, closingdate, quantity, closing, (quantity*closing)  "net" "stock values" s (account=2) , (quantity>0.000001) , (closingdate =(select  max(closingdate) "stock values" ( ticker = s.ticker) , (account=s.account)) ) 

but create report looks on tdbgrid that... report, grouped account recent distinct tickers added account. 4 days later, cannot crack this.

account                  value       1                   35,000.00       2                  122,132,32       3                       43.23 

i'm using nexus 3 on delphi 7.

any help, greatly appreciated.

larry

to me, looks have add group by:

select  account ,       sum(quantity*closing)    "stock_values" s   s.closingdate =          (         select  max(closingdate)             "stock values" s2           s2.ticker = s.ticker                  , s2.account = s1.account         ) group         account 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -