I have a question:
So I have the following data in a table”
id name city state phone price
234 Kevin Chicago IL 5555555555 550
234 Kevin Chicago IL 5555555555 NULL
234 Kevin Chicago IL 55555 NULL
234 Kevin Chicago IL NULL NULL
People have loaded data into a database and it is showing up like this because of character restrictions for each line…
So how can I tell my distinct query to get the most from each one..I just want this row returned:
234 Kevin Chicago IL 5555555555 550
And I cant do “where all rows are not null etc” because the last row can always be null too it depends.
Thanks a lot of your help!
Depending on what “the most” means exactly and depending on the data types of
phoneandprice, this could be your query:Edit: generalize query, get
phone&priceper person.phoneandpricecan come from different rows this way.The manual on aggregate functions:
So,
IFNULLorCOALESCEare not required here.