zoukankan      html  css  js  c++  java
  • 经典SQL题 1/25/50/100美分,多少种可能拼凑成2美元

    如题,这类问题就是看思路,很多面试的时候都会遇到,思路到了,面试官也就默许了。也许不是很复杂,但确实实在。

    1
    With t1 as( 2 select 200 n union all 3 select n - 25 from t1 where n-25>=0 -- 1 CENT 4 ), 5 t2 as( 6 select 200 n union all 7 select n - 25 from t2 where n-25>=0 -- 25 CENT 8 ), 9 t3 as( 10 select 200 n union all 11 select n - 50 from t3 where n-50>=0 -- 50 CENT 12 ), 13 t4 as( 14 select 200 n union all 15 select n - 100 from t4 where n-100>=0 -- 100 CENT 16 ) 17 select t1.n/1 [1美分], t2.n/25 [25美分], t3.n/50 [50美分], t4.n/100 [100美分] from t1,t2,t3,t4 18 where t1.n + t2.n + t3.n + t4.n = 200 19 order by t1.n desc 20 option(maxrecursion 0)

    希望我们能多多讨论研讨这些问题,提高自我sql水平,共同努力加油吧!
  • 相关阅读:
    UVA
    hdu 5584 LCM Walk
    UVA 10791 -唯一分解定理的应用
    UVA-10375 唯一分解定理
    UVA-11582
    UVA
    大连CCPC D
    java切割~~百万 十万 万 千 百 十 个 角 分
    js文字颜色闪烁
    日期比较大小给小的月份加1
  • 原文地址:https://www.cnblogs.com/life512/p/5333953.html
Copyright © 2011-2022 走看看