1
I need to bring only the records where the previous status was 1
, but which is currently 0
.
I have a table called solicitação
containing a field called VencimentoPausado
, where this field values are 1
or 0
, that is to say, 1
Chamados que estão em pausa
and 0
Chamados que não estão em pausa
.
I want to bring all the calls that are no longer on pause, ie before the era drive 1
and after the drive is 0
.
Remembering that if I put in the condition vencimentpausado
= 0, it will bring all called, but I want to bring only those called that before the status was 1.
Table Request
**Coluna** **Tipo**
AmbienteID int
AprovacaoRevisao bit
CalcularVencimentoAprovacao bit
ChamadoIntegradoID int
ConcluidoNoAtendimento bit
ConcluidoPeloSistema nchar
CustoTotal numeric
DataAberturaSistema datetime
DataAlteracao datetime
DataAprovacao datetime
DataBaseReabertura datetime
DataBaseSlaDinamico datetime
DataCancelamento datetime
DataCompromisso datetime
DataEntendimento datetime
DataPrevistaPriResp datetime
DataPrevistaRetorno datetime
DataRealFechamento datetime
DataRealPriResp datetime
DataRealRetorno datetime
Descricao varbinary
EPGerada bit
FusoHorarioID int
HorarioVeraoHistoricoID int
ImportadoAmbienteIntegrado bit
Incidente bit
IntegracaoConcluida bit
IntegracaoPausada bit
MacProcID int
MailPriRespEnviado nchar
ModID int
MotivoCompromissoID int
NatID smallint
Natureza nvarchar
NomeCliente nvarchar
Organiza nvarchar
OrgID int
OrgIDGrp int
PermitePausarVencimento bit
PermiteReclassificarVencimento bit
Produto nvarchar
ProID int
Projeto nvarchar
ProjID int
RecalculaVencimentoDataVisita bit
ReplicadoAmbienteIntegrado bit
Sequencia numeric
SeveridadeID int
SLAVlCalculado int
SLAVlRevCalculado int
SolAlterado nchar
solAprovado nchar
SolArqAtachado nchar
SolArqNome nvarchar
SolAssumido smallint
SolCalcularVencimento nchar
SolCaminho nvarchar
SolData datetime
SolDataConclusao smalldatetime
SolDataFechamento datetime
SolDataVisita smalldatetime
SolEnviaEmailTramite nchar
SolEnvioEmail datetime
SolEstagioID int
SolGrupoSAC nchar
SolicitacaoPai int
SolID int
SolIDCopia int
SolIDInclusao int
SolIDRef nvarchar
SolNivel int
SolNumTramite int
SolOrigem nchar
SolPerAlcada int
SolPrioridade smallint
SolQtdeReaberturas smallint
SolQtdFilho int
SolQtdTarFilho int
SolRetrabalho nchar
SolRetrabalhoResp nchar
SolStatus tinyint
SolSugestao nchar
SolTempoTelefone int
SolTipID int
SolTipoVinculo smallint
SolTitulo nvarchar
SolVencimento datetime
SolVerL int
SolVerO int
TempoCorridoSLADinamico bit
TempoGastoTotal int
TempoPriResp int
TempoRestanteVencimento int
TempoSlaReabertura int
TipoDescricao nvarchar
TipoFechamentoAutomatico int
TituloChamadoIntegrado nvarchar
UsuCentrodeCusto nvarchar
UsuIDAssociado int
UsuIDAtendenteViaFone int
UsuIDCliente int
UsuIDDistribuidor int
usuIDFilial int
UsuIDGrupoRespConclusao int
UsuIDInclusao int
UsuIDMatriz int
UsuIDReclamante int
UsuIDReclamanteAssociado int
UsuIDReclamanteDistribuidor int
usuIDReclamanteRepresentado int
usuIDRepresentado int
UsuIDResponsavel int
UsuIDSuporte int
UsuIDUltimaAlteracao int
UsuIDUltimoResp int
UtilizaSLADinamico bit
ValorServico numeric
ValorServicoCaminho numeric
ValorTotal numeric
VencimentoChamadoIntegrado bit
VencimentoInformadoManualmente bit
VencimentoPausado bit
VersaoL nvarchar
VersaoO nvarchar
This "before" assumes a date !? Try an exists on a subselect.
– Motta
https://forum.imasters.com.br/topic/560413-n%C3%A3o-ter-later-sql-oracle/#comment-2235723 see if it helps.
– Motta
Motta, no friend, refers to a bit field. Accepts only 1 or 0
– Renan Bessa
@Renanbessa: If there is no history of the movement, then there is no way. A log log log log analysis would be a possibility, but a laborious implementation. // It will be necessary to implement the change log.
– José Diz
In principle I only see solution if a column of "data_de_operation" is created in the table , the solution would be a trivial EXISTS.
– Motta