Select next record data to current record data

31 views
Skip to first unread message

Pugazharasan Thirumalai

unread,
May 26, 2017, 7:28:57 AM5/26/17
to OrientDB
If i execute the query, "select from custom_offer" then am getting the out like this,



PROPERTIES
rid
class
version
offer_text
offer_code
created_date
#265:2869custom_offer5Promotional OfferBFXVI3EY2017-01-25 00:00:00
#265:2871custom_offer5testL81KSPBZ2017-03-22 00:00:00
#265:2870custom_offer5test2017-04-12 00:00:00
#265:2868custom_offer5TestJHZZTNO42017-05-25 00:00:00


From the above result,
   Consider as 'created_date' as my offer start date,
   and we want the query for offer end date ie next record created_date is my offer end date of my first record.


For example,
   #265:2869 record offer Start date is 2017-01-25 00:00:00 and end date should be 2017-03-22 00:00:00.

So i want the query for getting next record value to first record data by select query.

Thanks and Regards,
T.Pugazharasan.

Ivan Mainetti

unread,
May 26, 2017, 5:50:56 PM5/26/17
to OrientDB
so, just to clarify, you want something like this?

Ivan Mainetti

unread,
May 26, 2017, 8:22:55 PM5/26/17
to OrientDB
you will need a javascript function (screenshots attached):




----

Ivan



Pugazharasan Thirumalai

unread,
May 27, 2017, 1:28:16 AM5/27/17
to orient-...@googlegroups.com
Hai Ivan,

      As you mentioned above first of all we have to write java script code, their i have run the query "select from custom_offer" after that we have to write some logic and the again we have to sun the query "select *,next_offer(@this.@rid).created_date as end_date from custom_offer".

    We are having thousands of data if we run  like that performance  will affect, But output what you got is correct. Kindly give query on single select query. 









Ivan Mainetti

unread,
May 29, 2017, 8:32:53 AM5/29/17
to OrientDB
I'm sorry, I understand that this method lacks in performance, but I'm afraid it's the only way. You can't do it with a single select query.
Reply all
Reply to author
Forward
0 new messages