SELECT
ID
SUM(CASE WHEN myProperty = 2 THEN 1 ELSE 0 END) as nbRowWithValueOf2,
SUM(CASE WHEN myProperty = 3 THEN 1 ELSE 0 END) as nbRowWithValueOf3
FROM Foo
GROUP BY ID
queryover = queryover
.Select(
Projections.Group<Foo>(c => c.ID),
Projections.Sum(
Projections.Conditional(
Restrictions.Where<Foo>(f => f.myProperty == MyEnum.Two),
Projections.Constant(),
Projections.Constant())),
Projections.Sum(
Projections.Conditional(
Restrictions.Where<Foo>(f => f.myProperty == MyEnum.Three),
Projections.Constant(),
Projections.Constant())));

生成SQL

SELECT this_.ID as y0_,
sum((case
when this_.myProperty = 2 /* @p0 */ then 1 /* @p1 */
else 0 /* @p2 */
end)) as y1_,
sum((case
when this_.myProperty = 3 /* @p3 */ then 1 /* @p4 */
else 0 /* @p5 */
end)) as y2_
FROM [Foo] this_
GROUP BY this_.ID

Nhibernate Case SUM的更多相关文章

  1. LeetCode 560. Subarray Sum Equals K (子数组之和等于K)

    Given an array of integers and an integer k, you need to find the total number of continuous subarra ...

  2. jqGrid插件getCol方法的一个改进

    jgGrid插件是非常常用的一个基于jQuery的表格插件,功能非常强大.我最近也频繁使用.但是这个插件也有一些不够完善的地方.比如这个getCol方法. getCol方法接受三个参数 colname ...

  3. UVALive 6911---Double Swords(贪心+树状数组(或集合))

    题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  4. UVALive 6916---Punching Robot(卢卡斯+容斥)

    题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  5. 8-06循环结构WHILE

    WHILE 循环语句可以根据某些条件重复执行一条SQL语句或一个语句块. 语句: WHILE(条件) BEGIN 语句或语句块 END 程序调试: ALT+F5启动调试 F9切换断点  F10遂过程, ...

  6. php-sql-parser sql防注入脚本

    <?php /** * SQL Parser from: http://code.google.com/p/php-sql-parser/ * License: New BSD */ class ...

  7. 241. Different Ways to Add Parentheses

    241. Different Ways to Add Parentheses https://leetcode.com/problems/different-ways-to-add-parenthes ...

  8. dojo/_base/lang源码分析

    dojo/_base/lang模块是一个工具模块,但几乎用dojo开发的app都会用到这个模块.模块中的方法能够在某些开发场景中避免繁冗的代码,接下来我们一起看看这些工具函数的使用和原理(仅仅是原理的 ...

  9. 2016暑假多校联合---Substring(后缀数组)

    2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...

随机推荐

  1. Git SSH Key 生成步骤

    it是分布式的代码管理工具,远程的代码管理是基于ssh的,所以要使用远程的git则需要ssh的配置. github的ssh配置如下: 一 . 设置git的user name和email: $ git ...

  2. 获取网页文档的URL和连接来源

    <script type="text/javascript">document.write("链接来源:"+document.referrer+&q ...

  3. putty mtputty 设置utf8编码

    2013年10月30日 10:02:36 先load你指定的ip 然后选择左侧目录中的windows->translation 再在右侧选择utf-8编码 选中后,点击左侧目录中的session ...

  4. google maps js v3 api教程(2) -- 在地图上添加标记

    原文链接 google maps javascript官方文档:https://developers.google.com/maps/documentation/javascript/ 我们在创建地图 ...

  5. osgEarth例子

    #include <osgViewer/Viewer>#include <osgViewer/ViewerEventHandlers>#include <osgGA/St ...

  6. July 31st, Week 32nd Sunday, 2016

    If you wept for the missing sunset, you would miss all the shining stars. 如果你为错过夕阳而哭泣,那你有可能也会错过灿烂的星空 ...

  7. CSS对字体单位的总结

    国内的设计师大都喜欢用px,而国外的网站大都喜欢用em和rem,那么三者有什么区别,又各自有什么优劣呢? PX特点 1. IE无法调整那些使用px作为单位的字体大小: 2. 国外的大部分网站能够调整的 ...

  8. POSIX线程--同时执行

    //#define _REENTRANT//#define _POSIX_C_SOURCE#include <iostream>#include <string>#includ ...

  9. SQL中行列转换Pivot

    --建表 ),课程 ),分数 int) --插入数据 ) ) ) ) ) ) 1.静态行转列(确定有哪些列) select 姓名, end)语文, end)数学, end)物理 from tb gro ...

  10. Java Hour 40 Maven ( 2 )

    有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. Hour 40 Maven 坐标 任何一个包都需要一个全世界唯一的id, Ma ...