Barclays Interview Question: Given a Tic table- I.e a tabl... | Glassdoor

Interview Question

Assistant Vice President Interview New York, NY

Given a Tic table- I.e a table that records Ticker, price

 , date/time during a trading day. Write a Query that will give you for each Ticker the final price of the day.
Answer

Interview Answer

1 Answer

0

SELECT TO_CHAR(TICK_TIMESTAMP, 'YYYYMMDD') TRADING_DAY, TICK_SYMBOL, TICK_PRICE FINAL_PRICE FROM TICK_TABLE WHERE (TICK_TIMESTAMP, TO_CHAR(TICK_TIMESTAMP, 'YYYYMMDD')) IN
(SELECT MAX(TICK_TIMESTAMP),
  TO_CHAR(TICK_TIMESTAMP, 'YYYYMMDD'),
  TICK_SYMBOL
FROM TICK_TABLE
GROUP BY TO_CHAR(TICK_TIMESTAMP, 'YYYYMMDD'), TICK_SYMBOL
)

Anonymous on Feb 12, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.