Question: I'm writing own project via Vue.js

I have several applications that include a set of common components and unique components.

I want to be able to configure configs for these applications, in which I could specify the necessary components and data for them, like this:

```
"load": [
    "Core.vue",
    "Accordion.vue",
    "Buttons.vue",
    "Table.vue",
    "etc"
],
"components": {
    "table": {
        "name": "title"
    },
    "accordion": {
        "tabs": {
            "tab1": {
                "name": 'tab1'
            },
            "tab2": {
                "name": 'tab2'
            }
        }
    }
}

```

and then components take this data and show it:

```
<template>
  <div> {{ name }} </div>
</template>

<script>
  export default {
    name: "Table",
    props: ['name']
  }
</script>

```

I think it can be JSON or .yml file (or any other format), but i don't understand how to process them?

Answer: 
This should work, assuming the earliest opening date is always going to include the master account number. 

First, isolate the account numbers and the initial opening date, then join that result set to your base table. I used a `CTE`, but a `sub-query` would accomplish the same thing. 

Using a `CTE`:

```
WITH masterOpen AS
  (
    SELECT
      master_accounts
     ,MIN(accountopendate) AS openDate
    FROM
      dbo.accounts
    GROUP BY
      master_accounts
  )
SELECT
  a.master_accounts
 ,a.accountopendate
 ,a.accountclosedate
FROM
  dbo.accounts AS a
JOIN
  masterOpen AS mo
    ON
      mo.master_accounts = a.master_accounts
      AND 
      mo.openDate = a.accountopendate
      AND 
      mo.openDate >= '2018-11-01' 
      AND 
      mo.openDate <= '2019-02-15';

```

`Sub-query` instead:

```
SELECT
  a.master_accounts
 ,a.accountopendate
 ,a.accountclosedate
FROM
  (
    SELECT
      master_accounts
     ,MIN(accountopendate) AS openDate
    FROM
      dbo.accounts
    GROUP BY
      master_accounts
  ) AS mo
JOIN
  dbo.accounts AS a
    ON
      mo.master_accounts = a.master_accounts
      AND 
      mo.openDate = a.accountopendate
      AND 
      mo.openDate >= '2018-11-01' 
      AND 
      mo.openDate <= '2019-02-15';

```

The date parameters could also be broken out into a `WHERE` clause if you prefer, but with an `INNER JOIN` it will yield the same results. For current versions of the SQL engine, it's more a matter of preference than performance.
Why not just use filter

```
SELECT distinct master_accounts, accountopendate, accountclosedate
FROM accounts where accountopendate>='2018-11-01' AND accountopendate<='2019-02-15'

```