Re: Aggregate string concatenation efficiency problem
- From: Rich P <rpng123@xxxxxxx>
- Date: Wed, 30 Jan 2008 17:39:24 -0600
fConcatChild("Consultants RIGHT JOIN ConsultantSales ON
Consultants.ConsultantID =
ConsultantSales.ConsultantID","SaleID","ConsultantFullName","Long",
[Sales].[SaleID]) AS Column5
<<
OK. I see your function call here. It looks like you are trying to
concatenate a consultant name. How about making this change:
...
FROM ((Customers INNER JOIN Sales ON Customers.CustomerID =
Sales.CustomerID) INNER JOIN VehicleSales ON Sales.SaleID =
VehicleSales.SaleID) Join Consultants t5 on t5.ID =
Customers.ConsultantID?
then replace fConcatChild with
Select ..., (t5.FirstName & ' ' & t5.LastName) As Column5...
or if this returns duplicates then
Select Distinct ..., (t5.FirstName & ' ' & t5.LastName) As Column5...
If the consultants table can't be joined to customers or vehicles
tables, you need to add a column so that you can join this table. I
will guess that there are many consultants to each customer? Then if a
customer has 10 consultants, you should have 10 rows for that customer.
This would be using 3rd Normal Form of the normalizing model (which is
what RDBMS is all about).
Note: (whith all due respect) if a sql statement is using a function
that calls a "Loop" -- that function needs to be scrapped. Loops should
be avoided in sql statements. Why? Do you have all day for your query
to run? The whole concept of normalization is to prevent redundant data
processing.
Once you have your resultset, then you can manipulate your data.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
.
- References:
- Prev by Date: Re: How to create a dynamic multipage Crosstab report with about 50 - 60 columns
- Next by Date: Re: Aggregate string concatenation efficiency problem
- Previous by thread: Re: Aggregate string concatenation efficiency problem
- Next by thread: Re: Aggregate string concatenation efficiency problem
- Index(es):
Relevant Pages
|
|