Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to write query to concatonate multiple entries

Status
Not open for further replies.

Toe

Programmer
Oct 26, 2001
71
GB
hi,

I have the following sceaio I want to write a query for, but can't think how to do it (assuming it is possible)
(well, i've simplified here to get to the point I want)

Imagin I have a 'rules' and a 'rule instruction' table as follows:

rules
-----
rule_code
rule_description


rule_instructions
-----------------

rule_code
instruction_seqno
instruction_text


what I want to be able to do is write a query that returns a single string comprising of the concatonated 'instruction_text' entries for a give rule

for example:

image the rule instruction table contains:

rule_code instruction_seqno instruction_text
--------- ----------------- -----------------
rule1 1 pick one of these
rule1 2 from each group
rule1 3 but not both
rule2 1 pick as many as you like
rule2 2 upto the maximum cost

what i would like is a seelct statement (or to write a view) that would return :


pick one of these from each group but not both

if i feed it 'rule1'

or
pick as many as you like upto the maximum cost

if I feed it 'rule2'

is this possible?

thanks,

andy
 
This is really a display layer problem. The front end should be doing the concatenation. Let the database server return the instructions in the proper order, and the front end can easily loop through that recordset, and concatenate as needed.
 


You could try using the LISTAGG function.
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top