home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,667 of 19,505   
   Bob Barrows to bill   
   Re: Combine Multiple Rows into one (deno   
   14 Jun 12 10:57:21   
   
   ed619d2f   
   From: reb01501@NOyahooSPAM.com   
      
   bill wrote:   
      
   > I have definitely not seen the part at the end where the sub-query is   
   > aliased as g, and then a parenthesized letter (y) is put at the end   
   >   
   > It appears that g.y becomes a column, but the syntax is confusing to   
   > me.   
   >   
   > Thanks,   
   >   
   > Bill   
   >   
      
   >  (   
   > SELECT DISTINCT ',' + CAST(SubID AS VARCHAR(11))   
   > FROM @Sample AS s   
   > WHERE s.ID = i.ID   
   > ORDER BY ',' + CAST(SubID AS VARCHAR(11))   
   > FOR XML PATH('')   
   > ) AS g (y)   
      
   A derived table is aliased with g, and the name of the column in the derived   
   table is aliased with y. Notice that the column name was not provided in the   
   derived table select statement. Even if it was, it would be overridden by   
   the alias.   
      
   Similar syntax can be seen with the CREATE VIEW statement:   
   CREATE VIEW ViewName (colname1,...,colnameN) AS   
   SELECT ...   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca