Redian新闻
>
SQL, recruiter发过来的面试题
avatar
SQL, recruiter发过来的面试题# JobHunting - 待字闺中
p*1
1
有兴趣做不? 我琢磨着, 出题的人是在寻找最优解 :)
We work with large datasets, and are always performance conscious since
extended processing times will impact our time to market. Keep this in mind
as you answer the following questions:
There is a table defined as:
CREATE TABLE [Positions](
[load_id] [int] NOT NULL,
[acct_cd] [varchar](20) NOT NULL,
[acct_num] [varchar](255) NULL,
[sec_id] [varchar](50) NOT NULL,
[long_sht_cd] [varchar](3) NOT NULL,
[sedol] [varchar](15) NULL,
[isin] [varchar](15) NULL,
[cusip] [varchar](9) NULL,
[sec_type] [varchar](8) NULL,
[sec_name] [varchar](100) NULL,
[currency_cd] [varchar](3) NULL,
[total_holding] [decimal](18, 4) NULL,
[mkt_price] [float] NULL,
[datetime_stamp] [datetime] NULL,
CONSTRAINT [pk_Positions] PRIMARY KEY CLUSTERED (
[load_id] ASC,
[acct_cd] ASC,
[sec_id] ASC,
[long_sht_cd] ASC )
)
This table holds account positions data that are appended to multiple times
a day
There are currently some 24 million rows in the table. Every time we append
additional positions we add approximately 32,000 entries to this table, and
all 32,000 entries will have the same load_id. The load_id is incremented by
one each time we load a batch of 32,000 entries (i.e. the first 32K entries
have load_id=1, the next 32K has load_id=2, etc...). The datetime_stamp
field shows the time at which the entries were loaded and is the same for
all 32K entries in a single load.
How would you efficiently retrieve the first set of positions for the
current day given the above table definition?
Example:
Today, positions were loaded into this table at 8am, 10am and 3pm. At 5pm
today we want to know what positions were loaded at 8am since that is the
first load that occurred today. Note that for any given day, there can be
different number of loads and the times that the loads occur will vary.
avatar
p*1
2
up
avatar
a*4
3
你的这两道题我都做过,当时agency联系我的,花了一下午做完,发回去,就再没消息
avatar
p*1
4
Mind sharing your answer here? 大家共同进步 :)

【在 a*********4 的大作中提到】
: 你的这两道题我都做过,当时agency联系我的,花了一下午做完,发回去,就再没消息
: 了

avatar
b*k
5
波士顿的一家金融公司?
avatar
g*c
6
你不会做就直接说不会做
直接请教这里的大牛帮你做出来
还尼玛最优解
sql有个鸡毛最优解

【在 p****1 的大作中提到】
: Mind sharing your answer here? 大家共同进步 :)
avatar
s*r
7
这根本不是SQL的题目,倒像是DW的构架,按照date进行sharding
或者搞个index table,只存loadid和timestamp,每个batch只有一行,join起来很容易
这个问题的层次好水
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。