patternsqlMinor
Two rows having null values merge into one row without null values
Viewed 0 times
rowswithoutmergenullintohavingtwoonevaluesrow
Problem
I have fetched the record from table like this:
But I want to reorder this table in this format:
Can any one help me to solve this, thank you very much in advance
Name Opp Bid Pro
----------------------------------------------------------------------
Admin 2 NULL NULL
Pragnya Sonal 7 NULL NULL
Priyanka Debnath 17 NULL NULL
Sanjeev Sasmal 2 NULL NULL
Subrajeet Sahoo 1 NULL NULL
Pragnya Sonal NULL 2 NULL
Pragnya Sonal NULL NULL 1But I want to reorder this table in this format:
Admin 2 NULL NULL
Pragnya Sonal 7 2 1
Priyanka Debnath 17 NULL NULL
Sanjeev Sasmal 2 NULL NULL
Subrajeet Sahoo 1 NULL NULLCan any one help me to solve this, thank you very much in advance
Solution
You can use grouping to get only one row per Name. If more than one row for the same Name and column have values you have to decide what to do with those values: do you want to see minimum, maximum, sum, average etc? So for example:
SELECT Name, min(Opp), min(Bid), min(Pro) FROM your_table GROUP BY NameCode Snippets
SELECT Name, min(Opp), min(Bid), min(Pro) FROM your_table GROUP BY NameContext
StackExchange Database Administrators Q#93628, answer score: 7
Revisions (0)
No revisions yet.