<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SQL Server (και άλλες databases)</title><link>https://www.dotnetzone.gr:443/cs/forums/28/ShowForum.aspx</link><description>Θέματα που αφορούν τον SQL Server (7.0, 2000, 2005) αλλά και Oracle, Access, DB2, MySQL, κλπ.</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Απ: δυναμικό pivot και ^%$@#%</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18941.aspx</link><pubDate>Sat, 21 Oct 2006 07:20:50 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18941</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18941.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18941</wfw:commentRss><description>&lt;P&gt;Πες ότι έχεις ένα πίνακα με τις πωλήσεις προϊόντων ανά μήνα και πελάτη. Το pivot μπορείς να το κάνεις με&lt;/P&gt;
&lt;P&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;select&lt;/span&gt; ProductID,CustomerID&lt;br /&gt;   &lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SUM&lt;/span&gt;(&lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;CASE&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHEN&lt;/span&gt; &lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Month&lt;/span&gt;=1 &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;THEN&lt;/span&gt; Sales &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;END&lt;/span&gt;) &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;As&lt;/span&gt; January,&lt;br /&gt;   &lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SUM&lt;/span&gt;(&lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;CASE&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHEN&lt;/span&gt; &lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Month&lt;/span&gt;=2 &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;THEN&lt;/span&gt; Sales &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;END&lt;/span&gt;) &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;As&lt;/span&gt; February,&lt;br /&gt;   ...&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;From&lt;/span&gt; ProductCustomerSales&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Group&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;By&lt;/span&gt; ProductID, CustomerID&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Η ίδια δουλειά με την εντολή Pivot γίνεται:&lt;/P&gt;
&lt;P&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; ProductID, CustomerID, &lt;br /&gt;   [1] &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;AS&lt;/span&gt; January,&lt;br /&gt;   [2] &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;AS&lt;/span&gt; February,&lt;br /&gt;   ...&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt; ProductCustomerSales&lt;br /&gt;   PIVOT (&lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SUM&lt;/span&gt;(Sales) &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FOR&lt;/span&gt; &lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Month&lt;/span&gt; &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;IN&lt;/span&gt; ([1],[2]...)) &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;AS&lt;/span&gt; P&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Αν τώρα τα δύο SELECT μοιάζουν μεταξύ τους ... μάλλον δεν είναι τυχαίο. Ακόμα και το ίδιο execution plan βγάζουν! Το μόνο που κερδίζεις με το PIVOT είναι τα CASE WHEN.&lt;/P&gt;</description></item><item><title>Απ: δυναμικό pivot και ^%$@#%</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18900.aspx</link><pubDate>Fri, 20 Oct 2006 22:11:04 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18900</guid><dc:creator>Δημήτρης Γκανάτσιος</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18900.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18900</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;table width="85%"&gt;&lt;tr&gt;&lt;td class="txt4"&gt;&lt;img src="/cs/Themes/aero/images/icon-quote.gif"&gt;&amp;nbsp;&lt;strong&gt;pkanavos wrote:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="quoteTable"&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top" class="txt4"&gt; Το ίδιο αποτέλεσμα μπορείς να πετύχεις με ένα group by. &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/BLOCKQUOTE&gt;&lt;br&gt;&lt;br&gt;έχουμε κάνα παραδειγματάκι σχετικά με το πώς επιτυγχάνεται αυτό;&lt;br&gt;</description></item><item><title>Απ: Re: δυναμικό pivot και ^%$@#%</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18834.aspx</link><pubDate>Thu, 19 Oct 2006 23:57:11 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18834</guid><dc:creator>agmarios</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18834.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18834</wfw:commentRss><description>&lt;P&gt;κι εγώ έχω αρχίσει να ψάχνομαι με group by. Κρίμα όμως γιατί χωρίς τη δυνατότητα δυναμικόυ ορισμού των στηλών το feature ακυρώνεται ( εκτός αν ξέρεις από πριν τις στήλες βέβαια)&lt;/P&gt;</description></item><item><title>Re: δυναμικό pivot και ^%$@#%</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18830.aspx</link><pubDate>Thu, 19 Oct 2006 23:11:41 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18830</guid><dc:creator>beastie</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18830.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18830</wfw:commentRss><description>Το είχα ψάξει και εγω πριν λίγο καιρό (είχα διαβάσει και το ΛΙΝΚ) αλλά δυστυχώς δεν βρήκα άλλη λύση... Σταμάτησα τα δυναμικά .... δυστυχώς...</description></item><item><title>Απ: δυναμικό pivot και ^%$@#%</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18767.aspx</link><pubDate>Thu, 19 Oct 2006 00:39:02 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18767</guid><dc:creator>agmarios</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18767.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18767</wfw:commentRss><description>&lt;P&gt;το ξέρω, αλλά έχω βρει 1-2 άρθρα &lt;A href="http://jbjgroup.com/dblog/2005/01/dynamic-pivot.html"&gt;http://jbjgroup.com/dblog/2005/01/dynamic-pivot.html&lt;/A&gt;&amp;nbsp;που το κάνουν (παράγουν το sql και το τρέχουν με exec ) αλλά όταν προσπαθώ να το κάνω στους δικούς μου πίνακες δεν&lt;img src="/cs/emoticons/emotion-6.gif" alt="Sad" /&gt; γι αυτό ρωτάω μήπως υπάρχει και καμιά άλλη πηγή.&lt;/P&gt;
&lt;P&gt;όσο για τη χρησιμότητά του όντος στη μόρφη που είναι τώρα θα συμφωνήσω απολύτως αλλά αυτές οι&amp;nbsp; λίγες γραμμές εντολών επί ένα μεγάλο πλήθος procedures κάτι κάνει.&lt;/P&gt;</description></item><item><title>Απ: δυναμικό pivot και ^%$@#%</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18766.aspx</link><pubDate>Thu, 19 Oct 2006 00:26:53 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18766</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18766.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18766</wfw:commentRss><description>Εν συντομία, ατύχησες. Το pivot δεν επιτρέπει τον ορισμό δυναμικής λίστας. Ο μόνος τρόπος είναι να φτιάξεις ένα sql string και να το εκτελέσεις. &lt;br /&gt;
&lt;br /&gt;
Εδώ που τα λέμε, η συγκεκριμένη εντολή δεν είναι τόσο χρήσιμη όσο φαίνεται. Το ίδιο αποτέλεσμα μπορείς να πετύχεις με ένα group by. Το pivot απλά σε γλυτώνει από μερικές γραμμές sql. Ακόμα και το execution plan που δημιουργείται για το pivot είναι όμοιο με του group by.</description></item><item><title>δυναμικό pivot και ^%$@#%</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18759.aspx</link><pubDate>Wed, 18 Oct 2006 22:46:54 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18759</guid><dc:creator>agmarios</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18759.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18759</wfw:commentRss><description>&lt;P&gt;υπάρχει κανένα άρθρο ή παράδειγμα για το πώς μπορώ να δηλώσω δυναμικά τις τιμές του &amp;lt;column_list&amp;gt; στο pivot statement;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item></channel></rss>