我有以下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子句过滤而不使用外部参数
发布评论