<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[שאילתת SUM על כמה עמודות + WHERE]]></title><description><![CDATA[<p dir="auto">יש לי טבלה עם 3 עמודות.<br />
סכום A<br />
סכום B<br />
ועמודה נוספת: תאריך</p>
<p dir="auto">אני רוצה לעשות SUM על כל סכום A<br />
וכן SUM על כל סכום B, אבל רק בתנאי שהעמודה "תאריך" קטנה או שווה ל NOW.</p>
<p dir="auto">חשוב לי מאוד המהירות של השאילתה הזו.</p>
<p dir="auto">כרגע אני עושה את זה בשני שאילתות.</p>
<p dir="auto">האם אפשר לעשות את זה בשאילתה אחת יותר מהירה?</p>
<p dir="auto">חשבתי אולי לעשות IF על ה SUM של סכום B.</p>
<p dir="auto">זה באמת יעזור?</p>
<p dir="auto">יש עוד פתרונות?<br />
לא אכפת לי גם לשנות מעט את מבנה הטבלה.</p>
<p dir="auto">תודה רבה.</p>
]]></description><link>https://tchumim.com/topic/5030/שאילתת-sum-על-כמה-עמודות-where</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Mar 2026 17:12:39 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/5030.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 31 Mar 2019 12:12:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Mon, 01 Apr 2019 10:03:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%A0%D7%A6%D7%A4%D7%9A">@<bdi>מנצפך</bdi></a> אמר ב<a href="/post/56083">שאילתת SUM על כמה עמודות + WHERE</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid">@<bdi>dovid</bdi></a><br />
ייתכן שאתה צודק.<br />
עבר זמן רב מאז (לפחות במושגים שלי).</p>
</blockquote>
<p dir="auto">אמממ..</p>
]]></description><link>https://tchumim.com/post/56084</link><guid isPermaLink="true">https://tchumim.com/post/56084</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 01 Apr 2019 10:03:20 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Mon, 01 Apr 2019 09:43:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid">@<bdi>dovid</bdi></a><br />
ייתכן שאתה צודק.<br />
עבר זמן רב מאז (לפחות במושגים שלי).<br />
לא זכרתי את קיום האשכול ההוא.</p>
<p dir="auto">אם אתה רואה צורך, תמחק את האשכול.</p>
]]></description><link>https://tchumim.com/post/56083</link><guid isPermaLink="true">https://tchumim.com/post/56083</guid><dc:creator><![CDATA[מנצפך]]></dc:creator><pubDate>Mon, 01 Apr 2019 09:43:42 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 15:55:45 GMT]]></title><description><![CDATA[<p dir="auto">לא הצלחתי להבין מה חדש בשאלה החדשה שלא נענה באשכול הישן.</p>
]]></description><link>https://tchumim.com/post/55959</link><guid isPermaLink="true">https://tchumim.com/post/55959</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Sun, 31 Mar 2019 15:55:45 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 14:51:11 GMT]]></title><description><![CDATA[<p dir="auto">לכל אחת</p>
]]></description><link>https://tchumim.com/post/55950</link><guid isPermaLink="true">https://tchumim.com/post/55950</guid><dc:creator><![CDATA[מנצפך]]></dc:creator><pubDate>Sun, 31 Mar 2019 14:51:11 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 14:43:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%A0%D7%A6%D7%A4%D7%9A">@<bdi>מנצפך</bdi></a> אמר ב<a href="/post/55945">שאילתת SUM על כמה עמודות + WHERE</a>:</p>
<blockquote>
<p dir="auto">לעשות 2 שאילתות לוקח בממוצע 115 ms.<br />
השאילתה המשולבת לוקחת בממוצע 130 ms.</p>
</blockquote>
<p dir="auto">115ms לכל אחת או לשתיהם?</p>
]]></description><link>https://tchumim.com/post/55947</link><guid isPermaLink="true">https://tchumim.com/post/55947</guid><dc:creator><![CDATA[clickone]]></dc:creator><pubDate>Sun, 31 Mar 2019 14:43:48 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 14:33:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/clickone">@<bdi>clickone</bdi></a><br />
נכון. עבר זמן מאז.</p>
<p dir="auto">בכל אופן לפי בדיקה מעכשיו (50K רשומות. לא הרבה).</p>
<p dir="auto">לעשות 2 שאילתות לוקח בממוצע 115 ms.<br />
השאילתה המשולבת לוקחת בממוצע 130 ms.</p>
<p dir="auto">ברור לאיפה הכיוון נוטה. לא?</p>
<p dir="auto">הבדיקה נעשתה דרך קליינט PgAdmin. אם זה משנה.</p>
]]></description><link>https://tchumim.com/post/55945</link><guid isPermaLink="true">https://tchumim.com/post/55945</guid><dc:creator><![CDATA[מנצפך]]></dc:creator><pubDate>Sun, 31 Mar 2019 14:33:55 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 14:21:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%A0%D7%A6%D7%A4%D7%9A">@<bdi>מנצפך</bdi></a><br />
הנה הדיון כאן<br />
<a href="https://tchumim.com/topic/4789/sum-%D7%A2%D7%9C-%D7%97%D7%9C%D7%A7-%D7%9E%D7%94%D7%AA%D7%95%D7%A6%D7%90%D7%95%D7%AA-sql">https://tchumim.com/topic/4789/sum-על-חלק-מהתוצאות-sql</a></p>
<p dir="auto">שם כתבת שתבדוק ותעדכן <img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61b.png?v=9d71ebe86e6" class="not-responsive emoji emoji-android emoji--stuck_out_tongue" style="height:23px;width:auto;vertical-align:middle" title=":P" alt="😛" /></p>
]]></description><link>https://tchumim.com/post/55944</link><guid isPermaLink="true">https://tchumim.com/post/55944</guid><dc:creator><![CDATA[clickone]]></dc:creator><pubDate>Sun, 31 Mar 2019 14:21:10 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 14:19:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/clickone">@<bdi>clickone</bdi></a> למה שלא יהיה יותר מהיר?</p>
]]></description><link>https://tchumim.com/post/55943</link><guid isPermaLink="true">https://tchumim.com/post/55943</guid><dc:creator><![CDATA[מנצפך]]></dc:creator><pubDate>Sun, 31 Mar 2019 14:19:55 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 14:18:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%A0%D7%A6%D7%A4%D7%9A">@<bdi>מנצפך</bdi></a><br />
בSQL SERVER אני לא בטוח.<br />
אני זוכר שהיה על זה דיון כאן בעבר</p>
]]></description><link>https://tchumim.com/post/55942</link><guid isPermaLink="true">https://tchumim.com/post/55942</guid><dc:creator><![CDATA[clickone]]></dc:creator><pubDate>Sun, 31 Mar 2019 14:18:45 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 14:17:45 GMT]]></title><description><![CDATA[<p dir="auto">אני על postgresql. אז הסינטק שונה.<br />
אבל העיקר המבנה.<br />
האם באמת זה יהיה יותר מהיר משני שאילתות? (קרוב לוודאי שכן).</p>
]]></description><link>https://tchumim.com/post/55941</link><guid isPermaLink="true">https://tchumim.com/post/55941</guid><dc:creator><![CDATA[מנצפך]]></dc:creator><pubDate>Sun, 31 Mar 2019 14:17:45 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 14:17:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%A0%D7%A6%D7%A4%D7%9A">@<bdi>מנצפך</bdi></a></p>
<p dir="auto">השאילתא מהזיכרון, אז יכול להיות שיש טעויות <img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f62e.png?v=9d71ebe86e6" class="not-responsive emoji emoji-android emoji--open_mouth" style="height:23px;width:auto;vertical-align:middle" title=":O" alt="😮" /><br />
הקוד אמור להתאים ל SqlServer</p>
<pre><code>select sum(a) as sum_a, sum(if(date&lt;=GETDATE(),1,0)) as sum_b from tbl
</code></pre>
]]></description><link>https://tchumim.com/post/55940</link><guid isPermaLink="true">https://tchumim.com/post/55940</guid><dc:creator><![CDATA[clickone]]></dc:creator><pubDate>Sun, 31 Mar 2019 14:17:06 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 13:39:31 GMT]]></title><description><![CDATA[<p dir="auto">אני צריך סיכום של כל אחד בנפרד.</p>
<p dir="auto">אבהיר שוב, על ה SUM של A אין תנאי. אלא רק על התנאי של B. כמובן ש WHERE רגיל אני יודע לעשות.</p>
]]></description><link>https://tchumim.com/post/55936</link><guid isPermaLink="true">https://tchumim.com/post/55936</guid><dc:creator><![CDATA[מנצפך]]></dc:creator><pubDate>Sun, 31 Mar 2019 13:39:31 GMT</pubDate></item><item><title><![CDATA[Reply to שאילתת SUM על כמה עמודות + WHERE on Sun, 31 Mar 2019 12:52:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%A0%D7%A6%D7%A4%D7%9A">@<bdi>מנצפך</bdi></a><br />
אתה צריך את הסיכום של A וB ביחד או בנפרד?<br />
אולי תכתוב כאן מה השאליתא שיש לך עכשיו?<br />
בכל מקרה בMYSQL אפשר לעשות ככה</p>
<pre><code>SELECT SUM(a) AS a_sum ,SUM(b) AS b_sum FROM `tabel` WHERE date &lt;= NOW

</code></pre>
<p dir="auto">ותתרגם את זה לסוג טבלה שיש לך</p>
]]></description><link>https://tchumim.com/post/55932</link><guid isPermaLink="true">https://tchumim.com/post/55932</guid><dc:creator><![CDATA[nigun]]></dc:creator><pubDate>Sun, 31 Mar 2019 12:52:19 GMT</pubDate></item></channel></rss>