Air defense actually wins whenever it is employed properly in sufficient quantity
First thing we need to understand is the cost. Cost of having air force compared to cost of having air defense based on AAA or SAMs is significantly higher. For air force, not only do you need planes, you also need air bases, hardened aircraft shelters, cost of aircraft maintenance is higher compared to maintenance cost of AAA and SAMs, training of pilots costs more then training of air defense crews etc ... Also, while it is relatively easy to hide AAA and SAMs while not in use, and use them from practically anywhere, aircraft are difficult to hide and then quickly prepare for combat. There were some experiments with fighters taking off from highways or land pads, but you simply cannot achieve high sortie ratio that way . All of this above lead to situation where air defense was usually employed by side which was inferior - militarily, economically and industrially. Underdogs usually lose wars, therefore relying on air defense may seem like loosing proposition, but in actually it is not so .
First recorded employments of AAA was in WW1. These were usually makeshift and converted artillery weapons, which from the start gave this appearance of underdog in contest vs aircraft. Nevertheless, as war progressed, AAA become more effective. One example of this was protection of observation balloons. Balloon busting became very dangerous do to anti-aircraft artillery and machine guns. Consequently, despite losses they were employed until the end of war by both sides. High altitude AAA against zeppelins and Gotha bombers was not particularly effective, nevertheless technology was improving towards the end of the war.
During WW2 , both AAA and aircraft were improving . German air defense (FlaK ) was very effective at low to mid altitudes. For example, during invasion of France in 1940 it was actually light FlaK units that covered Wehrmacht advance and protected vital bridges over Albert canal. Latter in the war, when Luftwaffe lost aerial superiority and sometimes even didn't show up it was German air defense that kept both Allied and Soviet tactical bombers away. Effectiveness of higher-caliber FlaK against high altitude bombers is debatable, some authors claimed it required over 3000 shells fired to down single bomber. Nevertheless, German air defense contributed to heavy psychological pressure on bomber crews because they could not shoot back. When employed in sufficient quantity and teamed up with fighters (like for example during Nuremberg raid 30-31 March 1944) they could inflict horrendous casualties on attackers. Opposite side also enjoyed some success with air defense: Soviets actually managed to repulse German bombing attacks against Moscow in 1941 due to very strong air defense, which saved the city from larger damage some other European cities endured. Britain and US usually neglected air defense units, relying more on fighters. Nevertheless, AAA was primary air defense of ships (which became critical in latter parts of war and Japanese employment of Kamikaze). Also, Allied AAA was very effective during operation Bodenplatte contributing to heavy LW casualties.
After WW2, if we skip Korean war (which didn't bring much new in air defense technology) , one glaring example where air defense actually won the war was of course Vietnam war. US aerial losses during Vietnam war were enormous, majority of them was inflicted by air defense (AAA and SAMs) . Soviets and Chinese did supply North Vietnam with relatively small fighter force, but large number of anti-aircraft guns and S-75 Dvina (NATO SA-2) SAM systems. Constant and heavy attrition of both USAF and USN aircraft, plus number of captured aircrew (which were not easy to replace) contributed to both US generals and US public losing the will to fight in this war.
Yom Kippur War is actually example of poor use of air defense system. Arab armies always had problems with employing high tech weaponry do low education levels and political promotions. In Yom Kippur War Egypt has received lot of state of the art Soviet technology, and their air defense units initially had some successes. Nevertheless , when US reinforces Israel with new planes (to replace losses) and when Israelis changed tactic Egyptian air defense did not manage to adapt. Even worse, Egyptian army left their protective air defense screen and was again decimated in the open.
Soviets had their own problems with guerillas armed with IR air defense missiles (Stinger) during Afghan war. These losses may not be so great as US losses in Vietnam, yet they contributed to lack of effectiveness of Soviet air force and consequently pull out from Afghanistan. Again, steady supply and reasonable training were key for success.
Finally, although Syrian civil war is still ongoing matter, it could be said that Russian intervention and especially their SAM batteries (S-400, S-300, Pantsir etc ) did deter US from another "bringing of democracy" action. Although Russian air defense did not fire directly on US or Israeli targets, they did help Syrians to defend themselves during recent cruise missile attacks, with large number of missiles being destroyed .