oracle11g - Select single row per unique field value with SQL Developer -


i have thousands of rows of data, segment of looks like:

+-------------+-----------+-------+   | customer id |  company  | sales |   +-------------+-----------+-------+   |    45678293 | sears     |    45 |   |    01928573 | walmart   |     6 |   |    29385068 | fortinoes |     2 |   |    49582015 | walmart   |     1 |   |    49582015 | joe's     |     1 |   |    19285740 | target    |    56 |   |    39506783 | target    |     4 |   |    39506783 | h&m       |     4 |   +-------------+-----------+-------+   

in every case customer id occurs more once, value in 'sales' same value in 'company' different (this true throughout entire table). need each value in 'customer id appear once, need single row each customer id.

in other words, i'd above table like:

+-------------+-----------+-------+   | customer id |  company  | sales |   +-------------+-----------+-------+   |    45678293 | sears     |    45 |   |    01928573 | walmart   |     6 |   |    29385068 | fortinoes |     2 |   |    49582015 | walmart   |     1 |   |    19285740 | target    |    56 |   |    39506783 | target    |     4 |     +-------------+-----------+-------+ 

if knows how can go doing this, i'd appreciate help. thanks!

well have been helpful, if have put sql generate data.

but might go like;

select customer_id, max(company) company, count(sales.*) customers <your joins , clause> group customer_id 

assumes; there many company , picks out number of occurance , sales data in different table.

hope helps.


Comments