# Does rom-sql support something like Sequel's #from\_self?

**URL:** <https://discourse.rom-rb.org/t/does-rom-sql-support-something-like-sequels-from-self/496>\
**Category:** Issues\
**Created:** [January 19, 2022, 4:18pm UTC](https://discourse.rom-rb.org/t/does-rom-sql-support-something-like-sequels-from-self/496 "2022-01-19T16:18:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wuarmin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/wuarmin/32/233_2.png) [@wuarmin](https://discourse.rom-rb.org/u/wuarmin)\
**Post date:** [January 19, 2022, 4:18pm UTC](https://discourse.rom-rb.org/t/does-rom-sql-support-something-like-sequels-from-self/496/1 "2022-01-19T16:18:19Z")

</div>

In Sequel there is a #from\_self method, which returns a dataset selecting from the current dataset.

[https://sequel.jeremyevans.net/rdoc/classes/Sequel/Dataset.html#method-i-from\_self](https://sequel.jeremyevans.net/rdoc/classes/Sequel/Dataset.html#method-i-from_self)

I want to achieve this with rom-rb. Is it possible?

I tried lots of things without success.

I.e.

```auto
      relation.from_self.select {
        [
          # sum(total_price).as(:total_price), # sequel dsl
          integer::sum(:total_price).as(:total_price), # rom dsl
        ]
      }.map.to_a

```

Thanks

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/solnic/32/279_2.png) [@solnic](https://discourse.rom-rb.org/u/solnic)\
**Post date:** [January 20, 2022, 8:00am UTC](https://discourse.rom-rb.org/t/does-rom-sql-support-something-like-sequels-from-self/496/2 "2022-01-20T08:00:22Z")

</div>

You can try to do `forward :from_self` within your Relation class and it will define `Relation#from_self` that should just work.

---

<div class="post-metadata">

**Author:** ![wuarmin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/wuarmin/32/233_2.png) [@wuarmin](https://discourse.rom-rb.org/u/wuarmin)\
**Post date:** [January 20, 2022, 9:00am UTC](https://discourse.rom-rb.org/t/does-rom-sql-support-something-like-sequels-from-self/496/3 "2022-01-20T09:00:25Z")

</div>

Wow! Thank you. That works! 😀
