Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Joining Temp Tables with Priority ?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Joining Temp Tables with Priority ?
Miscellaneous
Thread ID:
00655244
Message ID:
00655244
Views:
73
I have four seperate queries and want to join them into a single result set, giving the first result set priority over the first. Can anyone help?
	Declare @cAppName Char(30)
	Set @cAppName = devtst095.wsc'

	Select Distinct iBatchID , cTPAID , cFileName , cSubmittedBy , tCreateDt , 'Complete w/POINT ' as cStatus
		Into #TTCompletePoint
		From	AppBatchStd
		Where	iDel = 0 and cAppName = @cAppName
		and 	cStatusDesc like 'End of Batch Processing (with POINT%'
		Order by iBatchID Desc
	Select Distinct iBatchID , cTPAID , cFileName , cSubmittedBy , tCreateDt , 'Complete' as cStatus
		Into #TTComplete
		From	AppBatchStd
		Where	iDel = 0 and cAppName = @cAppName
		and 	cStatusDesc like 'Processing Complete%'
		Order by iBatchID Desc
	Select Distinct iBatchID , cTPAID , cFileName , cSubmittedBy , tCreateDt , 'Failed' as cStatus
		Into #TTFailed
		From	AppBatchStd
		Where	iDel = 0 and cAppName = @cAppName
		and 	cStatusDesc like 'Processing failed%'
		Order by iBatchID Desc
	Select Distinct iBatchID , cTPAID , cFileName , cSubmittedBy , tCreateDt , 'In Process' as cStatus
		Into #TTInProc
		From	AppBatchStd
		Where	iDel = 0 and cAppName = @cAppName
		and 	cStatusDesc like 'Start of Processing%'
		and	iBatchID Not In (Select iBatchID from AppBatchStd Where cStatusDesc Like 'Processing complete%')
		Order by iBatchID Desc
Thanks.
Next
Reply
Map
View

Click here to load this message in the networking platform