on 03-07-2018 3:33 PM
Hi Experts,
I want to make the autocode generation fms based on the customer group.
i am trying with below query, i am not getting the appropriate result.
can anyone help me on this.
declare @type as varchar(10)
declare @temp as char(15)
declare @group as int
declare @user as nvarchar(10)
set @group = (Select max(groupcode) from OCRD where GROUPCODE = $[OCRD.GROUPCODE])
set @type = (select max(cardtype) from OCRD where cardTYPe = $[OCRD.CARDTYPE]) set @user = (SELECT T0.USER_CODE FROM OUSR T0 WHERE t0.INTERNAL_K = $[USER])
BEGIN
SEt @temp=(select max(right(cardcode,4)) + 1 from ocrd where (cardtype=@type) and groupcode= @group)
set @temp= (select distinct max(left(y.GroupName,4)) from ocrd x inner join ocrg y on x.groupcode = y.groupcode where (x.cardtype=@type) and x.groupcode= @group) +'-' +@user +isnull(replicate(0,4-len(@temp)),'')+@temp
select cast(@temp as char(15)) End
Please help me to fix this query for FMS.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.