计算具有... SQL的行数(Count number of rows with having… SQL)
我必须计算一次是否列出UserId一次或多次,如果一个将“+1”添加到“新用户”,否则将“+1”添加到“返回用户”。
我做过:
select Count(distinct [UserId]) as 'Unique users' from [TelemetryData] where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick' /* returning */ select count(Id) as 'Returning users' from [TelemetryData] where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick' group by [UserId] having count(Id) > 1 /* returning */ select count(*) as 'New users' from [TelemetryData] where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick' group by [UserId] having count(*) = 1
我需要在“返回”和“新”用户中查询行的总数,就像在第一个查询中一样。 怎么做?
I have to count if UserId is listed one or more times and if one put +1 to "new users" else "+1" to "returning users".
Have I have done:
select Count(distinct [UserId]) as 'Unique users' from [TelemetryData] where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick' /* returning */ select count(Id) as 'Returning users' from [TelemetryData] where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick' group by [UserId] having count(Id) > 1 /* returning */ select count(*) as 'New users' from [TelemetryData] where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick' group by [UserId] having count(*) = 1
I need count total numer of rows in "returning" and "new" users query like in first query. How to do it?
原文:https://stackoverflow.com/questions/40129193
最满意答案
在我的例子中,net.sf.ehcache.constructs.web.filter.GzipFilter是罪魁祸首。 更改了从web.xml迁移到JavaConfig的行为。
In my case, it was the net.sf.ehcache.constructs.web.filter.GzipFilter that was the culprit. Changed behaviour moving from web.xml to JavaConfig.
相关问答
更多-
是不是有一款什么手机软件,可以很自然的拉长腿部?不是美图秀秀,有知道的不?[2022-10-20]
spring -
春天的英语怎么读?[2022-05-21]
spring -
spring mvc是什么?[2022-04-10]
Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面。Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块。使用 Spring 可插入的 MVC 架构,可以选择是使用内置的 Spring Web 框架还可以是 Struts 这样的 Web 框架。通过策略接口,Spring 框架是高度可配置的,而且包含多种视图技术,例如 JavaServer Pages(JSP)技术、Velocity、Tiles、iText 和POI。Spring M ... -
spring mvc post 乱码[2023-11-10]
在 server.xml中的Connector添加useBodyEncodingForURI='true'应该可以的 -
将@ResponseBody注释添加到您的控制器方法中,它将使用返回的值作为响应,而不是页面的路径。 如果您希望控制器的所有方法都返回直接数据(而不是页面路径),则可以使用@RestController而不是@Controller注释控制器。 Add the @ResponseBody annotation to your controller method and it will use the returned value as a response rather than as a path to a ...
-
在spring mvc中,使用Controllers,它始终是Request-> Controller(填充模型并选择视图) - > Response。 您可以使用ajax从任何资源(甚至是控制器)或jsp:useBean加载数据以显式调用某些业务逻辑或jsp:include以包含某个片段或自定义jsp标记。 in spring mvc, using Controllers, it is always Request->Controller(populates model and chooses view) ...
-
乱码页面输出Spring MVC(Garbled page output Spring MVC)[2023-04-17]
在我的例子中,net.sf.ehcache.constructs.web.filter.GzipFilter是罪魁祸首。 更改了从web.xml迁移到JavaConfig的行为。 In my case, it was the net.sf.ehcache.constructs.web.filter.GzipFilter that was the culprit. Changed behaviour moving from web.xml to JavaConfig. -
我认为你所追求的并不完全与春天有关。 如果要在运行较长任务时显示某些消息,则需要使用Ajax / JQuery在执行较长任务时显示一些文本/动画。 我建议你看一下这个例子,看看你如何用JQuery做这样的事情。 I think that what you are after is not exactly spring related. If you want to display some message while a longer task is running, you will need to us ...
-
你快到了:) JSON只是一种对象格式,因此您必须返回一个具有键:值对的对象。 @RequestMapping(value = "/ex/foos", method = RequestMethod.GET, produces = "application/json") @ResponseBody public MyJSONRespone getFoosAsJsonFromREST() { MyJSONRespone myResponse = new MyJSONRespone(); myRespon ...
-
请删除注释@ResponseBody 。 删除注释后,应将浏览器重定向到所需的页面。 此注释指示控制器中的方法返回的值应绑定到Web响应正文。 在您的情况下,您不需要:您需要Spring来呈现页面/resources/Post.html,因此不需要这个注释。 Please remove the annotation @ResponseBody. Your browser should be redirected to the desired page once the annotation is remov ...