Home > database >  Select data from multiple tables, but the results have repeat, how to weigh?
Select data from multiple tables, but the results have repeat, how to weigh?

Time:10-06

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;=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 fruits
All need to keep, if can set up a primary key, is ntc_id

CodePudding user response:

@ February 16
Shows that there is an error

CodePudding user response:

refer to 6th floor qq_41947073 response:
@ February 16
Shows that there is an error

Access database?

CodePudding user response:

Yes, is for the use of direct access

CodePudding user response:

refer to the eighth floor qq_41947073 response:
, is for the use of direct access

Access is not very well. If there is no good method, can according to ntc_id and sat_name two columns of what value is one of the biggest aggregation, such as freq_min
Then read in and read out a table now, three fields
  • Related