Home > database >  Compare the ORACLE single table identifies whether a field increases
Compare the ORACLE single table identifies whether a field increases

Time:09-18

SOS

CodePudding user response:

The LHQ + ck + SFQ and compare

CodePudding user response:

reference 1st floor yaiger response:
put LHQ + ck + SFQ and compare

Can you write a example bosses I was a new thanks sum of can but can't write...

CodePudding user response:

 case when LHP & gt; Lag (LHP) over (partition by the name the order by nd) or 
LHP & gt; Lag (ck) over (partition by the name the order by nd) or
LHP & gt; Lag (SFQ) over (partition by the name the order by nd)
Then 'add'
The else 'end

CodePudding user response:

Out thank you thank you very much  [2

CodePudding user response:

SELECT t. *,
(SELECT DECODE (COUNT (0), 0, 'not' AND 'add') FROM table_name WHERE tt tt. The name=t.n ame AND tt. Nd - 1=t.n d AND (tt) LHQ & lt; T.l hq OR tt. Ck & lt; Tc k OR tt. SFQ & lt; T.s fq) z
The FROM table_name t ORDER BY t.n ame, t.n d;

CodePudding user response:

reference 5 floor AHUA1001 reply:
SELECT t. *,
(SELECT DECODE (COUNT (0), 0, 'not' AND 'add') FROM table_name WHERE tt tt. The name=t.n ame AND tt. Nd - 1=t.n d AND (tt) LHQ & lt; T.l hq OR tt. Ck & lt; Tc k OR tt. SFQ & lt; T.s fq) z
The FROM table_name t ORDER BY t.n ame, t.n d;

Thank you I also tried this seems not to you...

CodePudding user response:

The future, I think this question is the focus of the position offset function, the use of lag, and lead a more complex I didn't remember several keywords
With t as
(select the 'Ming' name, 0 LHQ, ck, 1 0 SFQ, nd 2015
The from dual
Union all
Select 'Ming' name, 0 LHQ, 1 ck, 0 SFQ, 2016 nd
The from dual
Union all
Select 'Ming' name, 1 LHQ, 1 ck, 2 SFQ, 2017 nd
The from dual
Union all
Select 'Ming' name, 1 LHQ, 2 ck, 1 SFQ, 2018 nd
The from dual
Union all
Select 'Ming' name, 3 LHQ, 0 ck, 0 SFQ, 2019 nd
The from dual)
The select m. *,
Case
The when LHQ & gt; LHQ or ck & gt; Ck_next or SFQ & gt; Sfq_next then
'add'
The else
'not'
End as flag
The from (select name,
LHQ,
Lag (LHQ) over (order by nd) lhq_next,
Ck,
Lag (ck) over (order by nd) ck_next,
SFQ,
Lag (SFQ) over (order by nd) sfq_next,
Nd
The from t) m

CodePudding user response:

refer to 6th floor qq_40175369 response:
Quote: refer to the fifth floor AHUA1001 reply:
SELECT t. *,
(SELECT DECODE (COUNT (0), 0, 'not' AND 'add') FROM table_name WHERE tt tt. The name=t.n ame AND tt. Nd - 1=t.n d AND (tt) LHQ & lt; T.l hq OR tt. Ck & lt; Tc k OR tt. SFQ & lt; T.s fq) z
The FROM table_name t ORDER BY t.n ame, t.n d;

Thank you I also tried this seems not to you...

Add the index name + nd

CodePudding user response:

Analysis function of the hierarchical query, recursive, with the model, the connection, the scalar subquery, stored procedures can be achieved, considering the efficiency, after three into consideration, considering the simple level, analysis function is preferred,
  • Related