Question: I have a booking table with the following columns:

id, start\_date, end\_date

I want to know which days have had the most bookings over my dataset.

I can use dayofweek() on the start date and group by this also and use a count(\*). But I also want to include the days between the start of booking and end.

An example output wouldbe 

```
dayofweek     count(*)
1             1
2             1
3             1
4             2
5             3
6             3
7             1

```

for the following set

```
id       start_date          end_date
1        2017-10-01          2017-10-07
2        2017-10-04          2017-10-07
3        2017-10-06          2017-10-08

```

Answer: 
ok now I solved this error simply by creating a method and creating and initializing FragmentManager and FragmentTrasaction there and it works great for me. May be error was due to the fact that we can commit FragmentTransaction only for once for multiple commit we need to declare it again and again btw thnks. here's my method: 

```
private void openFragment(final Fragment fragment)   {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.fragment, fragment);
        transaction.addToBackStack(null);
        transaction.commit();

    }

```
You need a brand new transaction for your each click but you are beginning only once in your `onCreate()` and try to `commit()` multiple times. You can update your code as follows to get rid of the problem:

```
// Remove following two lines...
// FragmentManager fragmentManager;
// FragmentTransaction fragmentTransaction;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener(this);
}

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    switch (item.getItemId()) {
        case R.id.navigation_home:
            fragmentTransaction.replace(R.id.fragment, new HomeFragment()).commit();
            return true;
        case R.id.navigation_dashboard:
              fragmentTransaction.replace(R.id.fragment, new Dashboardfragment()).commit();
            return true;
        case R.id.navigation_notifications:
                fragmentTransaction.replace(R.id.fragment, new NotificationFragment()).commit();
            return true;
    }
    return false;
}

```