PL SQL - 新手 - MAX fron表和平均值

时间:2015-08-04 20:05:31

标签: sql oracle

我有按日期和24小时间隔的帐号表

ACCT#;日期; hour1,hour2,hour3 ...... hour24

每个帐户可能有多达365天#我希望找到所有间隔的平均值以及每个帐号的最大间隔#。我试图添加样本数据,但因为这是我的第一篇文章,我无法附加它(需要+10个帖子) -

" CUSTOMER_NUMBER" "日期" " est_hb_0000" " est_hb_0100" " est_hb_0200" " est_hb_0300" " est_hb_0400" " est_hb_0500" " est_hb_0600" " est_hb_0700" " est_hb_0800" " est_hb_0900" " est_hb_1000" " est_hb_1100" " est_hb_1200" " est_hb_1300" " est_hb_1400" " est_hb_1500" " est_hb_1600" " est_hb_1700" " est_hb_1800" " est_hb_1900" " est_hb_2000" " est_hb_2100" " est_hb_2200" " est_hb_2300"

提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

在重新构建并填充表后,此SQL应该会让您关闭。

Select Customer, Date, HourOfDay, NumAccts
From ActivityStats
Where Customer = 'zzz'
  and Date = 'Dt'
  and RowNumber < 11
Order By NumAccts Desc