Home > database >  Python or SQL information completion problem
Python or SQL information completion problem

Time:09-19

Name card phone
1 empty 123
2, 888 empty
1, 777 empty
2 empty 00

Like the data to repair JiCheng
Name card phone
1 777 123
2 888 00

CodePudding user response:

What are the rules of a filling?

CodePudding user response:

The
reference 1/f, February 16 response:
filling what are the rules?
the example above is according to the name as

CodePudding user response:

There will be someone there? Please answer

CodePudding user response:

Written in MSSQL, similar to mysql
The test data
 -If not object_id (N 'Tempdb for.. # T ') is null 
Drop table # T
Go
The Create table # T (int [name], [id] nvarchar (23), [mobile] nvarchar (23))
Insert # T
Select 1, N 'empty', N '123' union all
Select 2, N '888', N 'empty' union all
Select 1, N '777', N 'empty' union all
Select 2, N 'empty', N '00'
Go
- the end of the test data
SELECT DISTINCT * FROM (
SELECT
A. name,
CASE WHEN a. id='empty' THEN b. ELSE a. id card and id card end AS
='empty' cell phone CASE WHEN a. THEN b. mobile phones ELSE a. end AS mobile phone
The FROM
# T a
LEFT the JOIN
# T b
ON b. name=a. name
AND b. phone & lt;> A. cell phone
AND b. id & lt;> A. id
) t


CodePudding user response:

references on February 16, 4/f response:
written in MSSQL, similar to mysql
The test data
 -If not object_id (N 'Tempdb for.. # T ') is null 
Drop table # T
Go
The Create table # T (int [name], [id] nvarchar (23), [mobile] nvarchar (23))
Insert # T
Select 1, N 'empty', N '123' union all
Select 2, N '888', N 'empty' union all
Select 1, N '777', N 'empty' union all
Select 2, N 'empty', N '00'
Go
- the end of the test data
SELECT DISTINCT * FROM (
SELECT
A. name,
CASE WHEN a. id='empty' THEN b. ELSE a. id card and id card end AS
='empty' cell phone CASE WHEN a. THEN b. mobile phones ELSE a. end AS mobile phone
The FROM
# T a
LEFT the JOIN
# T b
ON b. name=a. name
AND b. phone & lt;> A. cell phone
AND b. id & lt;> A. id
) t


thank you, I try
  • Related