小编JIe*_*mON的帖子

当存在null时,SQL查询返回null而不是SUM

我有一个简单的表,例如:

create table #test(x int, y int)
insert into #test values(null, 1)
insert into #test values(1, 1)
insert into #test values(1, 2)
insert into #test values(2, 2)
insert into #test values(3, 2)
Run Code Online (Sandbox Code Playgroud)

我需要通过分组获得总和,但如果组具有空值,则获取null而不是sum.我可以用两个查询来做到这一点:

1) select y, case when AVG(x)<>SUM(x)/COUNT(*) then null else SUM(x) end from #test
group by y
2) select y, CASE WHEN EXISTS(select * from #test innerTest where innerTest.y=outerTest.y and x is null) then null else sum(x) end 
from #test outerTest group by y
Run Code Online (Sandbox Code Playgroud)

哪个查询性能更好?还有其他解决方案吗?

sql performance

2
推荐指数
1
解决办法
982
查看次数

Flex项目与IE11中的另一项重叠

我有两个div:

  1. top div包含一个占用多行的长文本
  2. 较低的div有min-heightflex-grow: 1

当我减少窗口出现滚动时,然后在chrome中一切都正确显示.但在IE11中,顶部div减少到一行,其文本位于底部div的顶部.

我可以修复它只为顶部div的内容设置一些宽度(它适用于固定宽度,或钙宽度,但无法使用百分比宽度)如何在不设置宽度或宽度百分比(width:100%)的情况下修复它?

body,
html {
  height: 99%;
  padding: 0;
  margin: 0;
}

.flexcontainer {
  width: 25%;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid lime;
}

.allspace {
  flex-grow: 1;
  min-height: 300px;
  background-color: yellow;
}

.longtext {
  background-color: red;
}

.textcontainer {
  border: 1px solid magenta;
  /*IE work correctly only when specified width. by example: width:calc(25vw - 2px);*/
}
Run Code Online (Sandbox Code Playgroud)
<div class="flexcontainer">
  <div class="longtext">
    section 1 with long name section …
Run Code Online (Sandbox Code Playgroud)

html css css3 flexbox internet-explorer-11

2
推荐指数
1
解决办法
5156
查看次数

标签 统计

css ×1

css3 ×1

flexbox ×1

html ×1

internet-explorer-11 ×1

performance ×1

sql ×1