The FROM pub_ssn INNER JOIN (com_el INNER JOIN GRP ON com_el. Ntc_id=GRP. Ntc_id) ON pub_ssn. Ntc_id=GRP. Ntc_id
WHERE
(((GRP) d_rcv) & gt; # 12/28/2018 #) AND ((GRP) freq_min) & gt;=7235) AND ((GRP) freq_max) & lt;=7243))
OR (((GRP) d_rcv) & gt; # 12/28/2018 #) AND ((GRP) freq_min) & lt;=7235) AND ((GRP) freq_max) & gt; 7235))
OR (((GRP) d_rcv) & gt; # 12/28/2018 #) AND ((GRP) freq_min) & lt; 7243) AND ((GRP) freq_max) & gt;=7243))
Such as below the picture, I just want to set the primary key to draw the red place, don't repeat to delimit the red place, could you tell me how to rewrite should be?

CodePudding user response:
Xie asked, can you tell me the GRP grp_id, GRP. Freq_min, GRP. Freq_max, these a few field values: what are you going to do?CodePudding user response:
@ one tree forest _Those columns don't move, just will filter out the results of the data in a deleted ntc_id and sat_name repeat
CodePudding user response:
These two lines, what do you keep?CodePudding user response:
SELECT * FROM (
SELECT *, ROW_NUMBER () OVER (PARTITION BY ntc_id, sat_name ORDER BY GETDATE ()) rn FROM (
The SELECT com_el. Adm, com_el ntc_id, com_el. Sat_name, GRP. Grp_id, GRP. D_rcv, GRP. Freq_min, GRP. Freq_max, pub_ssn. Ssn_ref, pub_ssn. Ssn_no
The FROM pub_ssn INNER JOIN (com_el INNER JOIN GRP ON com_el. Ntc_id=GRP. Ntc_id) ON pub_ssn. Ntc_id=GRP. Ntc_id
WHERE
(((GRP) d_rcv) & gt; # 12/28/2018 #) AND ((GRP) freq_min) & gt;=7235) AND ((GRP) freq_max) & lt;=7243))
OR (((GRP) d_rcv) & gt; # 12/28/2018 #) AND ((GRP) freq_min) & lt;=7235) AND ((GRP) freq_max) & gt; 7235))
OR (((GRP) d_rcv) & gt; # 12/28/2018 #) AND ((GRP) freq_min) & lt; 7243) AND ((GRP) freq_max) & gt; T=7243)))) t1 WHERE an rn=1
CodePudding user response:
@ the net of selling fruitsAll need to keep, if can set up a primary key, is ntc_id
CodePudding user response:
@ February 16Shows that there is an error

CodePudding user response: