使用where子句过滤而不使用外部参数

编程入门 行业动态 更新时间:2024-10-23 13:25:05
本文介绍了使用where子句过滤而不使用外部参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下SQL代码,用于从表中检索字符串日期。如何在没有参数的情况下检索字符串日期?

Hi, i have the following SQL codes which is to retrieve the string date from a table. How can i retrieve the string date without a parameter?

CREATE TABLE #TargetDateTblxC(IssueID VARCHAR(100), TargetDate VARCHAR(100)) INSERT [#TargetDateTblxC] SELECT issueid, [fielddata] AS TargetDate FROM rndbug.dbo.gemini_customfielddata WHERE customfieldid = 215 AND LEN(fielddata) > 0 AND SUBSTRING(fielddata, 5, 1) = 8 --how do i write behind the SUBSTRING(fielddata, 5, 1) without having to write like '+@month+'

i我不太确定如何解释我的问题 在决赛桌下,我将不得不接受我从上面得到的TargetDate的数量表并使用它来划分我从另一个表中获得的总百分比。例如。 450 / COUNT(TargetDate) 百分比将按月分类或逐月(12个月)。但我的问题是当我除以TargetDate计数时,它假设除以每个月,但COUNT(TargetDate)将忽略月份并除以总计数。例如。对于六月是COUNT(TargetDate)是2和八月COUNT(TargetDate)是3.然后六月的百分比是200和八月是150,假设是200/2和150/3但现在它将需要200/5和150 / 5这不是我想要的。

i am not quite sure how to explain my question under the final table, i will have to take the count of the TargetDate i get from the above table and use it to divide the total percentage i get from another table. E.g. 450/COUNT(TargetDate) the percentage would be sorted or group by month(12 months). But my problem is when i divide by the TargetDate count, it suppose to be divide by each respective month but the COUNT(TargetDate) would ignore the month and divide by the total count. E.g. for June is COUNT(TargetDate) is 2 and August COUNT(TargetDate) is 3. Then the percentage in June is 200 and August is 150, suppose is 200/2 and 150/3 but now it will take 200/5 and 150/5 which is not i want.

推荐答案

我仍然不清楚你的问题。但是你觉得你应该在查询中使用逐个月来获得结果。 I am not still clear with your question. But feel you should get the result by using "group by month" in your query.

更多推荐

使用where子句过滤而不使用外部参数

本文发布于:2023-10-18 12:56:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504291.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子句   而不   参数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!