﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / recursive query / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 19:11:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: recursive query</title><link>http://www.sqlservercentral.com/Forums/Topic597814-338-1.aspx</link><description>Hi Mark,It works...thank you very much for the answer and your timergds,richard</description><pubDate>Thu, 06 Nov 2008 20:51:37 GMT</pubDate><dc:creator>tspot</dc:creator></item><item><title>RE: recursive query</title><link>http://www.sqlservercentral.com/Forums/Topic597814-338-1.aspx</link><description>The ID in table2 is the same ID with Table1-&amp;gt;ID (not parent)BTW, Mark has solved this issue</description><pubDate>Thu, 06 Nov 2008 20:45:41 GMT</pubDate><dc:creator>tspot</dc:creator></item><item><title>RE: recursive query</title><link>http://www.sqlservercentral.com/Forums/Topic597814-338-1.aspx</link><description>[code]WITH CTE AS (SELECT ID,NAME AS DEPTFROM TABLE1WHERE PARENTID=-1UNION ALLSELECT t.ID,c.DEPTFROM CTE cINNER JOIN TABLE1 t ON t.PARENTID=c.ID)SELECT t.DATE,c.DEPT,t.QTYFROM CTE cINNER JOIN TABLE2 t ON t.ID=c.IDORDER BY t.DATE,t.QTY[/code]</description><pubDate>Thu, 06 Nov 2008 02:37:03 GMT</pubDate><dc:creator>Mark-101232</dc:creator></item><item><title>RE: recursive query</title><link>http://www.sqlservercentral.com/Forums/Topic597814-338-1.aspx</link><description>[quote][b]tspot (11/5/2008)[/b][hr][font="Courier New"]Hi,I have these tables :TABLE1ID   NAME      PARENTID===  ========= ========1    SALES       -12    MIS         -13    LANG         14    RAMA         35    ANDRE        26    ROY          5 TABLE2DATE    ID     QTY=====   ===    =====01/01   3      101/01   5      202/01   6      6 How to make a query for below result:DATE    DEPT    QTY--------------------01/01   SALES    101/01   MIS      202/01   MIS      6[/font][/quote]What is the criteria of joining between these two tables, i mean how can we relate these two tables</description><pubDate>Wed, 05 Nov 2008 21:46:48 GMT</pubDate><dc:creator>krayknot</dc:creator></item><item><title>RE: recursive query</title><link>http://www.sqlservercentral.com/Forums/Topic597814-338-1.aspx</link><description>But if you see the data carefully the name that i want to display is department name</description><pubDate>Wed, 05 Nov 2008 20:24:45 GMT</pubDate><dc:creator>tspot</dc:creator></item><item><title>RE: recursive query</title><link>http://www.sqlservercentral.com/Forums/Topic597814-338-1.aspx</link><description>That won't be a recurrsive query... it'll be a simple join between the two tables joined on ID.</description><pubDate>Wed, 05 Nov 2008 19:44:00 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>recursive query</title><link>http://www.sqlservercentral.com/Forums/Topic597814-338-1.aspx</link><description>[font="Courier New"]Hi,I have these tables :TABLE1ID   NAME      PARENTID===  ========= ========1    SALES       -12    MIS         -13    LANG         14    RAMA         35    ANDRE        26    ROY          5 TABLE2DATE    ID     QTY=====   ===    =====01/01   3      101/01   5      202/01   6      6 How to make a query for below result:DATE    DEPT    QTY--------------------01/01   SALES    101/01   MIS      202/01   MIS      6[/font]</description><pubDate>Wed, 05 Nov 2008 19:30:27 GMT</pubDate><dc:creator>tspot</dc:creator></item></channel></rss>