Member since
Points: 350

6/27/2012 2:56:30 PM

Comma Separated Detail from a sub table

* This article, and all our great SQL (General) documentation, Is available on the SQL (General) menu

This concept applies to any Header Detail table relationship, for this example we'll talk about the SOP header/detail/serial lot relationship. We want back one line for each item in the order; and we want the serial/lots concatenated into one field. The final result will look like this:

The entire query that we need is below. Run the second script first, it's the function that makes the whole thing work.

 This code is based on the TWO database
Version: GP 2010
Section: SQL Scripts
Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables