sql - How to optimise query containing subqueries from same table? -
I am very new to MS SQL
I have a table that includes all comments from customer As well as admin I have applied the index, but since The non-unique content of the column is not very helpful. Is there any other way to write these types of questions, or should I consider reducing the table itself? returns the above query results, but is very slow, I want to know that my query op Is not optimized or is the selection of the choice of my table wrong? You did not provide any data to test, but my intuition is to run sub-questions as GETDATE ()) and ([T.]. [Ticket ID] One more thing that accelerates is that you can use the equality operator instead of Comments [history] [[ID] [IT] [int] identification (1,1) null, [comet] [daytime] null constant [df_commentsHistory_CommDate] DEFAULT (Dot), [comment] [varchar] (255) NULL, [Comments] [varchar] NULL (max), [TransactionID] [float] NULL, [splitnumber] [varchar] (50) NULL, [MfrId ] [Int] NULL, [[show original] [bit] null, [showwire] [bit] null, [isspons] [beet] null, [crust eme ] [Primary] [primary]
with sections will run faster Because they will run once and the main result will be in the set of resistance to running for each line. As [Content]] [DBA] [Comments] as history [T1] as [T1] where [T1] [T1] [MT] [T1] as [customer]. [T1]. [Like comment '% client%'] by the group [T1]. [Ticket ID], as a liability (SELECT [T2]. [Ticket ID], Min ([T2]. [CommDate] from AS [Commodate] [DBO] [Comments] AS [T2] where (not [T2]. [Commented as '% client%']] [T2] by group [Ticket ID ], [CommDate2], [t0]. [TicketId], [T.]. [TransactionID], [T1]. [CommDate] AS [AskedMinDate] [Convert Convert] , [T2]. [Commodate] AS [ResponseMinDate] [TCT] [T] on [T1] at [T1]. [TTIID] = [T.]. [Ticket ID] [T2] [T2ID] = [T0] at [T2]. [Ticket] where [converter (date, [T.]] [CommDate] gt; = DATEAD (mm, -1) Order By [T]] [Ticket ID] DESC, [T.] [Commodity];
as operator, like
[comment] = 'customer' . It depends on when the
from the comment column Amgri fully
'client' is , then it is to note the client or not. If it is, you can use the equality operator. If not, then the column always starts with starts with
'client' or this value is in the same condition so that you can use or like < / em>
LEFT ([CommentFrom], 6) = 'Client' .
Comments
Post a Comment