If anyone is interested....
This is what I came up with.  Thanks for the direction and help Paul

CREATE PROCEDURE webclientacctholdmonthly2 @ColumnNumberAsAnInteger
varchar(100), @caccountid int, @thisdate DateTime
AS

IF @ColumnNumberAsAnInteger = 4
BEGIN
SELECT      dbo.holdingsMonthly.holdingDate, dbo.holdingsMonthly.shares,
dbo.holdingsMonthly.costLocal, dbo.holdingsMonthly.costBase,
dbo.holdingsMonthly.pctPort, dbo.holdingsMonthly.priceLocal,
dbo.holdingsMonthly.priceBase, dbo.holdingsMonthly.mktValueLocal,
dbo.holdingsMonthly.mktValueBase, dbo.holdingsMonthly.currency,
dbo.securities.secName, dbo.securities.symbol, dbo.securities.country,
dbo.securities.sector,
CASE
WHEN @ColumnNumberAsAnInteger = 2 THEN securities.country
WHEN @ColumnNumberAsAnInteger = 3 THEN sector
WHEN @ColumnNumberAsAnInteger = 4 THEN convert(varchar(100),pctPort)
ELSE secName
END AS SortCol
FROM         dbo.holdingsMonthly, dbo.securities
WHERE       dbo.holdingsMonthly.secid = dbo.securities.secid AND
                   (dbo.holdingsMonthly.accountID = @caccountid) AND
(dbo.holdingsMonthly.holdingDate = @thisdate)
ORDER BY SortCol DESC
END
ELSE
SELECT      dbo.holdingsMonthly.holdingDate, dbo.holdingsMonthly.shares,
dbo.holdingsMonthly.costLocal, dbo.holdingsMonthly.costBase,
dbo.holdingsMonthly.pctPort, dbo.holdingsMonthly.priceLocal,
dbo.holdingsMonthly.priceBase, dbo.holdingsMonthly.mktValueLocal,
dbo.holdingsMonthly.mktValueBase, dbo.holdingsMonthly.currency,
dbo.securities.secName, dbo.securities.symbol, dbo.securities.country,
dbo.securities.sector,
CASE
WHEN @ColumnNumberAsAnInteger = 2 THEN securities.country
WHEN @ColumnNumberAsAnInteger = 3 THEN sector
WHEN @ColumnNumberAsAnInteger = 4 THEN convert(varchar(100),pctPort)
ELSE secName
END AS SortCol
FROM         dbo.holdingsMonthly, dbo.securities
WHERE       dbo.holdingsMonthly.secid = dbo.securities.secid AND
                   (dbo.holdingsMonthly.accountID = @caccountid) AND
(dbo.holdingsMonthly.holdingDate = @thisdate)

ORDER BY SortCol

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to