Is it possible to get value from previous record in FetchXML? - fetchxml

As the title states, just wondering if it's possible to make reference to a value in the previous record in FetchXML? I can do this fairly easily in SQL (even without resorting to analytic function LAG) but as FetchXML doesn't allow subqueries, I'm not sure if it's possible to do this? Can anyone help?
Thanks

This is not possible with the current FetchXML specification.

Related

MS Access - Age of record calculated field

I am new to Access but I have experience with Excel and Power BI. I could use a little help with what is probably a very simple problem for most of you.
I searched for a simple solution to this same problem quite extensively before posting here. I tried adapting solutions for similar problems to my problem, but I'm just not familiar enough with Access yet to bridge that gap.
I have a [request date] field. I want my [age] field to return the number of days since that request date. Sounds simple enough. o_O
Through trial and error I eventually determined that I cannot do this without a query (please prove me wrong?). And why can't I use datediff() or date() in a calculated field, anyway? Grr.
So I set up an update query for a new field (called [today]) with the expression "date()".
Then I set the [age] field to be calculated with the expression [today]-[request date].
This gives me the result I want for [age]. But now I'm thinking I need to write an autoexec macro to run this query every time the database is opened so that [today] stays current.
At this point I stopped. Seems like a lot of work for such a simple problem. I hate being inefficient. I'm hoping someone out there knows a more elegant solution that might also teach me some new tricks, too.
Thank you in advance for your help!
Calculated fields belong in queries, not tables.
Just use a SELECT query. It could be as simple as
SELECT *, DateDiff("d",[request date],Date()) AS Age
FROM yourTable
and then use that query wherever you would use the table.

SAP HANA Calculate percentage in a script calculation view

I was wondering if there was a way to achieve this kind of aggregation :
In practice: using (I think) CE_AGGREGATION how is possible to create a percentage formula like the one in "calculated column"?
I try a lot of combination (CE_PROJECTION,CE_AGGREGATION, CE_CALC...) but no ones of them works.
This because it seems that the script do a kind of sum(A/b*100), but I would like to obtain sum(a)/sum(b)*100. In graphical mode is instead very simple!
Someone has an idea about how to reproduce that?
Really, don't bother using the CE_-functions anymore.
Use SQL instead.
This is not only much easier but also SAP HANA has more options to rewrite and optimize the statements internally.
This should then lead to more options for better performance.
Anyhow, to do calculations like that, there is the CE_CALC function, that you can use within a CE_PROJECTION function.
Again: stop using CE_-functions. SQL is King!

how to make different types of report in one sql statement?

I need to make a query that makes a report using different tables, based on a value of one field.
This value affects the 'select' as well as the 'from' and 'where'.
At first I thought using dynamic SQL, but since the 'from' and 'where' are also changing it won't work.
Now I'm thinking about making views for all the different report types and I have 2 questions about is, since I'm pretty new with this:
how do I use the views in the main query?
is there a better idea that could work for the problem?
Thanks in advance
how do I use the views in the main query?
Just like every table.
is there a better idea that could work for the problem?
I don't know if it's better but you can use UNION (if number of columns in every report is equal and their types are the same).

Understanding random ordering in Rails + postgresql

So, I'd like to do some random ordering when displaying data the code I have at this point is:
Timsheet.limit(1).offset(RANDOM(Timesheet.count)).first
I know that postgresql's (RANDOM) syntax is different than MYSQL's (RAND()) and Oracles (dbms_random.value) syntax.
I'd just like to confirm that my code is correct, from what I understand it's doing is, it's grabbing the first row, and offsetting the data in a random order?
Please help clear this up, thanks!
I think the following will work with all DBMS's
Timsheet.offset(Random.new.rand(Timsheet.count)).first

SmartGWT Isomorphic Datasource aggregate SQL functions

I'm looking to get the maximum value of a column from an instance of a com.isomorphic.datasource.DataSource. Is this possible?
A general "run this sql against this datasource" would be particularly helpful, as later I'll be looking to do more, including getting a row "count" for some criteria.
I could technically fetch ALL records and iterate through them myself, though this is clearly less than optimal. I can't seem to find anything related in the SmartGWT docs.
I'm using:
SmartGWT Power v3.0.p20121127
In DataSource, applyFilter() methods with different different arguments are there you can use one of them and using Criteria and AdvancedCriteria you can do.