I am stuck with the following issue. I have 1 table that looks like this:

```
field_number.. Value  
````````````````````````````````  
1 ......................... 1  
2 ..........................1  
3 ......................... 2  
4 ..........................2   

```

etc.

I want to group different fieldnumbers and have an average for the value column. So the output should be:

```
field_number................Value

name(1,2)......................   1..............       ((1+1)/2)

name(3,4)......................   2..............       ((2+2)/2)

```

I have checked previous questions but cannot find any question that covers this issue (I might search on the wrong keywords though). So if this has already been covered my appologies, but any help or a point to a previous answer would be appreciated.

\*\* =============UPDATE============= \*\*

I went through your suggestions but did not get it right. So I am trying to be more specific. I almost have the result I want apart from the fact I want to have a fixed value in one of my columns. I have the following query:

```
Select 
Avg(wp_rg_lead_detail.value),
wp_rg_lead_detail.field_number,
From
wp_rg_lead_detail
Where
wp_rg_lead_detail.field_number In (15, 17, 24) A
UNION
Select
Avg(wp_rg_lead_detail.value),
wp_rg_lead_detail.field_number,
From
wp_rg_lead_detail
Where
wp_rg_lead_detail.field_number In (16, 108, 18)

```

etc.

This gives me a table with two columns

```
wp_rg_lead_detail.value................field_number
4.3 (average)..............................15 (first value of av calculation)

```

What I want is to change the field number (15 in this case) in a fixed value (text). What and how should I add this to the query?
['https://Stackoverflow.com/questions/33668984', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5554171/']
Try join

```
SELECT a.`begin_date`, IF(b.`end_date` IS NOT NULL, b.`end_date`, a.`end_date`), a.`employer_id`
FROM `mytable` a
LEFT JOIN `mytable` b ON a.`employer_id` = b.`employer_id` AND a.`end_date` = b.`begin_date`
LEFT JOIN `mytable` c ON a.`employer_id` = c.`employer_id` AND a.`begin_date` = c.`end_date`
WHERE c.`id` IS NULL

```

But you should rebuild your schema.
You can use `MIN(),MAX()` if you want to get earlier and later times.

```
SELECT MIN(begin),MAX(end),employeesId
    FROM table_name
    GROUP BY employeesId

```

Hope this helps