Viewing 15 posts - 1,036 through 1,050 (of 1,473 total)
Your CTE is fine, all that needs to change is your final select.
SELECT MAX(an.id)...
November 26, 2008 at 8:01 am
Good call Barry.
[font="Courier New"]SELECT DISTINCT
D.Ohorseid,
RC.RaceCount,
WC.WinCount,
TPM.TotalPrizeMoney,
CASE WHEN ISNULL(RC.RaceCount,0) = 0 THEN 0
WHEN ISNULL(WC.WinCount,0) = 0 THEN 0
ELSE TPM.TotalPrizeMOney / (WC.WinCount / RC.RaceCount)
END PrizeMoneyCalc
FROM decouting...
November 26, 2008 at 7:53 am
LEFT JOIN (SELECT OHorseID, SUM(b.rprize1) TotalPrizeMoney
FROM outing a
...
November 26, 2008 at 7:35 am
I get that. However, if you can show me a specific example of what you want to return, I can understand what you're trying to accomplish. Different metadata is...
November 26, 2008 at 6:27 am
All that lurking and you haven't seen us sending people to the same post over and over? :hehe: Please refer to the article in my signature for an example...
November 26, 2008 at 6:23 am
Could you be more specific? Providing a table with definition and exactly what you want to return from that table would help. See the link in my signature...
November 26, 2008 at 6:10 am
For the sample data provided, please give your expected results.
Are they:
10031832
100311592
100311602
100311612
800003925051
10031140012
10031800003920
?
November 26, 2008 at 6:07 am
Drop and recreate the table.
(You can use SSMS to generate a sql script for the table)
That said, the identity column is really there for uniqueness and the actual numbers shouldn't...
November 25, 2008 at 5:06 pm
Yerp, change this:
TPM.TotalPrizeMOney / (WinCount / RaceCount)
To this:
CASE WHEN RaceCount = 0 THEN 0
WHEN WinCount = 0 THEN 0
...
November 25, 2008 at 5:03 pm
Please refer to the link in my signature for how to post table structure / sample data for future questions. Doing so would have gotten you a tested answer....
November 25, 2008 at 3:23 pm
When you make the modifications Lynn suggested, please do it in this thread rather than creating another one. Creating multiple threads on the same issue is confusing and annoys...
November 25, 2008 at 2:59 pm
Please refer to the article in my signature on how to post sample data on this forum.
November 25, 2008 at 2:56 pm
You just add in the extra handler:
Select Case @tst1 When 1 Then 'Yes' Else 'No' END ,
Case @tst2 When 1 Then 'Yes'...
November 25, 2008 at 2:50 pm
Viewing 15 posts - 1,036 through 1,050 (of 1,473 total)