﻿
update ai 
	set ai.Dom_ID_tafsiliType = 
	(
		case g.Dom_ID_Type
			when 1111	/*اشخاص*/ then 50
			when 1112 /*هزينه*/ then 48
			when 1113 /*درآمد (خدمات)*/ then 52
			when 1114 /*بانک*/ then 49
			when 1115 /*صندوق*/ then 51
			when 1116 /*شرکت*/ then 53
			when 1117 /*اموال*/ then 54
			when 1118 /*طبقات اموال*/ then 1967
			when 1119 /*کالا*/ then 1968
			when 1120 /*گروه کالا*/ then 1969
			when 1121 /*قرارداد*/ then 1970
			when 1122 /*پروژه*/ then 1971
			when 1123 /*ساير*/ then 446
		end
	)
from AccountItem ai 
	inner join GroohAccountItem g on ai.Gro_AI_ID = g.id	
	inner join Domain dom on dom.ID = g.Dom_ID_Type
where 
	ai.Dom_ID_Level in (450,451,452,453) and
	ai.ID > 0 and
	ai.Dom_ID_tafsiliType is null