Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?

SQL
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 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.
Posted
Comments
Maciej Los 16-Jul-14 1:59am    
Sample data might help to understand your question. Please, improve your question.

1 solution

I am not still clear with your question. But feel you should get the result by using "group by month" in your query.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900