Calculated value from multiple rows in selection set
Consider this query
SELECT WELL.UWI
FROM geo_formation A, WELL
WHERE ( (select min(top_depth)
from geo_formation B
where B.uwi = A.uwi
and form_id = 'WDBD' )
(select min(top_depth)
from geo_formation C
where C.uwi = A.uwi
and form_id = 'VKNS' )
) > 10
AND A.uwi = WELL.UWI
AND A.FORM_ID IN ('WDBD','VKNS')
ORDER BY WELL.UWI, A.FORM_ID
The question asked by the query is
Show me all the entities (entities are identified by WELL.UWI)
where the distance between the geological formations (identified by WDBD and VKNS)
is greater than 10
The distance in question of course is calculated in the
(select min(top_depth)
from geo_formation B
where B.uwi = A.uwi
and form_id = 'WDBD' )
(select min(top_depth)
from geo_formation C
where C.uwi = A.uwi
and form_id = 'VKNS' )
portion of the where clause.
** My question:
Is there any way to get this calculated value to be part of the selection list
ie.
SELECT WELL.UWI, 'the calculated value in question'
FROM geo_formation A, WELL ...
Thanks Barbara; once again your solution to one of my problems works like a charm.
On top of that, I learned something important; I did not know that one can essentially achieve the same results as creating a temporary table by including the appropriate (select ...) in the from clause.
Thanks again.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Barbara Boehmer ([email protected]):
SELECT a.uwi, (bmin - cmin) distance
FROM well a,
(SELECT uwi, MIN (top_depth) bmin
FROM geo_formation
WHERE form_id = 'WDBD'
GROUP BY uwi) b,
(SELECT uwi, MIN (top_depth) cmin
FROM geo_formation
WHERE form_id = 'VKNS'
GROUP BY uwi) c
WHERE b.uwi = a.uwi
AND c.uwi = a.uwi
AND bmin - cmin > 10
ORDER BY a.uwi
/<HR></BLOCKQUOTE>
null
Similar Messages
-
How To Concatenate Column Values from Multiple Rows into a Single Column?
How do I create a SQL query that will concatenate column values from multiple rows into a single column?
Last First Code
Lesand Danny 1
Lesand Danny 2
Lesand Danny 3
Benedi Eric 7
Benedi Eric 14
Result should look like:
Last First Codes
Lesand Danny 1,2,3
Benedi Eric 7,14
Thanks,
David JohnsonStarting with Oracle 9i
select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
from
(select last, first, code, row_number() over(partition by last, first order by code) rn
from a)
connect by last = prior last and first = prior first and prior rn = rn -1
start with rn = 1
group by last, first
LAST FIRST CODES
Lesand Danny 1,2,3
Benedi Eric 7,14Regards
Dmytro -
How to get one value from multiple duplication for a key figure field
Hi expert,
I have a infoprovider, with following format:
employee hourly_rate action_type count of action
there are multiple rows for each employee, I want to create query as follows:
employee hourly_rate action_type count of action
in which hourly_rate is constant , only retriving one value from multiple rows for one employee, count of action should be summarized.
how to get this hourly_rate.
Many Thanks,Hi,
put the employee in rows panel -> reaming object put it in free char panel.
suppress the all result rows for the all object except employee .
select the object -> go to query properties -> select display tab -> select result rows -> select suppress.
select the employee -> go to query properties -> select display tab -> select result rows -> select always display. - now it will give employee wise hourly rate summarize data.
Thanks,
Phani. -
How can i select some row from multiple row in the same group of data
I want to select some row from multiple row in the same group of data.
ColumnA
Column B
1 OK
1 NG
2 NG
2 NG
3 OK
3 OK
I want the row of group of
ColumnA if ColumnB contain even 'NG'
row , select only one row which Column B = 'NG'
the result i want =
ColumnA Column B
1 NG
2 NG
3 OK
Thank youThat's some awful explanation, but I think this is what you were driving at:
DECLARE @forumTable TABLE (a INT, b CHAR(2))
INSERT INTO @forumTable (a, b)
VALUES
(1, 'OK'),(1, 'NG'),
(2, 'NG'),(2, 'NG'),
(3, 'OK'),(3, 'OK')
SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
FROM @forumTable f
LEFT OUTER JOIN @forumTable f2
ON f.a = f2.a
AND f.b <> f2.b
GROUP BY f.a -
Concatenate a column value across multiple rows - PDW
We are using PDW based on SQL2014. We require an efficient logic on how to concatenate a column value across multiple rows. We have the following table
T1
(CompanyID, StateCD)
Having following rows:
1 NY
1 NJ
1 CT
2 MA
2 NJ
2 VA
3 FL
3 CA
We need a code snippet which will return following result set:
1
CT,NJ,NY
2
MA,NJ,VA
3
CA,FL
We have tried built-in function STUFF with FOR XML PATH clause and it is not supported in PDW. So, we need a fast alternative.Hi Try this:
SELECT * INTO #ABC
FROM
SELECT 1 AS ID,'NY' AS NAME
UNION
SELECT 1 AS ID,'NJ' AS NAME
UNION
SELECT 1 AS ID,'CT' AS NAME
UNION
SELECT 2 AS ID,'MA' AS NAME
UNION
SELECT 2 AS ID,'NJ' AS NAME
UNION
SELECT 2 AS ID,'VA' AS NAME
UNION
SELECT 3 AS ID,'FL' AS NAME
UNION
SELECT 3 AS ID,'CA' AS NAME
)A
CREATE TABLE ##CDB (ID INT, NAME NVARCHAR(800))
DECLARE @TMP VARCHAR(MAX),
@V_MIN INT,
@V_MAX INT,
@V_COUNT INT
SELECT @V_MIN=MIN(ID),@V_MAX=MAX(ID) FROM #ABC
SET @V_COUNT=@V_MIN
WHILE @V_COUNT<=@V_MAX
BEGIN
SET @TMP = '' SELECT @TMP = @TMP + CONVERT(VARCHAR,NAME) + ', ' FROM #ABC
WHERE ID=@V_COUNT
INSERT INTO ##CDB (ID, NAME) SELECT @V_COUNT AS ID ,CAST(SUBSTRING(@TMP, 0, LEN(@TMP)) AS VARCHAR(8000)) AS NAME
SET @V_COUNT=@V_COUNT+1
END
SELECT * FROM ##CDB
OR
SELECT * INTO #ABC
FROM
SELECT 1 AS ID,'NY' AS NAME
UNION
SELECT 1 AS ID,'NJ' AS NAME
UNION
SELECT 1 AS ID,'CT' AS NAME
UNION
SELECT 2 AS ID,'MA' AS NAME
UNION
SELECT 2 AS ID,'NJ' AS NAME
UNION
SELECT 2 AS ID,'VA' AS NAME
UNION
SELECT 3 AS ID,'FL' AS NAME
UNION
SELECT 3 AS ID,'CA' AS NAME
UNION
SELECT 5 AS ID,'LG' AS NAME
UNION
SELECT 5 AS ID,'AP' AS NAME
)A
CREATE TABLE ##CDB (ID INT, NAME NVARCHAR(800))
DECLARE @TMP VARCHAR(MAX),
@V_MIN INT,
@V_MAX INT,
@V_COUNT INT
SELECT @V_MIN=MIN(ID),@V_MAX=MAX(ID) FROM #ABC
SET @V_COUNT=@V_MIN
WHILE @V_COUNT<=@V_MAX
BEGIN
SET @TMP = '' SELECT @TMP = @TMP + CONVERT(VARCHAR,NAME) + ', ' FROM #ABC
WHERE ID=@V_COUNT
SELECT @V_COUNT AS ID ,CAST(SUBSTRING(@TMP, 0, LEN(@TMP)) AS VARCHAR(8000)) AS NAME INTO #TEMP
INSERT INTO ##CDB (ID, NAME) SELECT ID, NAME FROM #TEMP WHERE NAME<>''
DROP TABLE #TEMP
SET @V_COUNT=@V_COUNT+1
END
SELECT * FROM ##CDB
Thanks Shiven:) If Answer is Helpful, Please Vote -
Please - immediate help needed parsing csv values into multiple rows
Hello, we have a very immediate need to be able to parse out a field of comma separated values into individual rows. The following is an example written in SQL Server syntax which does not work in Oracle.
The tricky part is that each ROUTES can be a different length, and each CSV can have a different number of routes in it.
Here is an example of the table ("Quotes") of CSV values I want to normalize:
TPNUMBER ROUTES
1001 1, 56W, 18
1002 2, 16, 186, 28
Here is an example of what I need it to look like:
TPNUMBER ROUTES
1001 1
1001 56W
1001 18
1002 2
1002 16
1002 186
1002 28
Here is the "Tally" table for the query below:
ID
1
2
3
4
5
6
7
And finally, here is the query which parses CSV values into multiple rows but which does not work in Oralce:
SELECT TPNUMBER,
NullIf(SubString(',' + ROUTES + ',' , ID , CharIndex(',' , ',' + ROUTES + ',' , ID) - ID) , '') AS ONEROUTE
FROM Tally, Quotes
WHERE ID <= Len(',' + ROUTES + ',') AND SubString(',' + Phrase + ',' , ID - 1, 1) = ','
AND CharIndex(',' , ',' + ROUTES + ',' , ID) - ID > 0
It may be necessary to use a cursor to loop through the CSV table and process each row (a loop within another loop...) but this is beyond my comprehesion of PL/SQL.
Many thanks in advance for your advice/help.
apkNot sure what you are trying to do with the last step, but this should work for the first part. I assume you would use sqlldr but I just did inserts instead. You might need more than 5 "routes" in the csv. You could put some reasonable max on that number of columns:
SQL>create table t_csv
2 (TPNUMBER varchar2(20),
3 ROUTE_1 VARCHAR2(5),
4 ROUTE_2 VARCHAR2(5),
5 ROUTE_3 VARCHAR2(5),
6 ROUTE_4 VARCHAR2(5),
7 ROUTE_5 VARCHAR2(5),
8 ROUTE_6 VARCHAR2(5) );
Table created.
SQL>INSERT INTO t_csv (TPNUMBER,ROUTE_1,ROUTE_2) values( '1001 1', '56W', '18' );
1 row created.
SQL>INSERT INTO t_csv (TPNUMBER,ROUTE_1,ROUTE_2,ROUTE_3) values( '1002 2', '16', '186', '28');
1 row created.
SQL>create table t_quotes(
2 tpnumber NUMBER,
3 routes VARCHAR2(5));
Table created.
SQL>DECLARE
2 L_tpnumber NUMBER;
3 L_route VARCHAR2(5);
4 begin
5 for rec in (select * from t_csv) loop
6 L_tpnumber := SUBSTR(rec.tpnumber,1,INSTR(rec.tpnumber,' ')-1);
7 L_route := SUBSTR(rec.tpnumber,INSTR(rec.tpnumber,' ')+1);
8 insert into t_quotes values( L_tpnumber, l_route );
9 if rec.route_1 is not null then
10 insert into t_quotes values( L_tpnumber, rec.route_1 );
11 end if;
12 if rec.route_2 is not null then
13 insert into t_quotes values( L_tpnumber, rec.route_2 );
14 end if;
15 if rec.route_3 is not null then
16 insert into t_quotes values( L_tpnumber, rec.route_3 );
17 end if;
18 if rec.route_4 is not null then
19 insert into t_quotes values( L_tpnumber, rec.route_4 );
20 end if;
21 if rec.route_5 is not null then
22 insert into t_quotes values( L_tpnumber, rec.route_5 );
23 end if;
24 end loop;
25 end;
26 /
PL/SQL procedure successfully completed.
SQL> select tpnumber, routes from t_quotes;
TPNUMBER ROUTE
1001 1
1001 56W
1001 18
1002 2
1002 16
1002 186
1002 28
7 rows selected. -
Creating stacked graph from multiple rows
Hi!
I am trying to create a stacked bar graph from multiple rows. My data looks like this:
Date_Time Error_Code Count
16-01-2011 12:00 100 10
16-01-2011 12:00 200 15
16-01-2011 12:10 100 5
16-01-2011 12:10 200 7
16-01-2011 12:20 300 20
16-01-2011 12:20 400 6
I want to stack the count of each error_code on top of each other for every time group.
Is this possible?
Br
CasperHi,
can you try
- select the graph in the Structure Window or the visual editor
- open Property Inspector
- Press Pencil Icon
- Click "Swap Bars with x-Axis"
Frank -
Reg : Concatenation of a column value with multiple rows... URGENT
Hello,
Could any of u help me in concatenating a column value with
multiple rows ???
For ex : I've the following data from emp table :
DEPTNO ENAME
10 KING'S
30 BLAKE
10 CLARK
10 TOM JONES
30 ALLEN
30 JAMES
20 SMITH
20 SCOTT
20 MILLER
10 MILLER
20 rajeev
I want the following output :
deptno Concat_value
10 KING'S,CLARK,TOM JONES,MILLER
20 Rajeev,MILLER,SMITH,SCOTT
30 BLAKE,ALLEN,JAMES
Thanks in Advance,
SriniHello Naveen,
Thanks for ur answer. But I need a single SQL query for getting
what I want. I know the solution in PL/SQL.
Please try it in a single SQL....
Thanks again,
Srini -
How to paste calculated values from Numbers?
When I copy calculated values from Numbers and paste into a table in Pages, I get an image like the one below. Non calculated values paste fine.
To get around this issue, I paste the calculated values into TextWrangler, then copy from there and paste into Pages. Is there a way to go directly from Numbers to Pages with calculated values?Hi 4th Space,
I you are pasting into a table in Pages, follow Jeffs instructions.
I you are not pasting into a table, this works. Copy the cells in Numbers. Go to your Pages document and under the Edit Menu > Paste and Match Style. It works like Paste Values.
Ian. -
Retrieve Title field values from multiple lists and add into another list
Hi , Iam trying to retrieve Title field value from multiple lists. and add them into another list. using Javascript. Can any one help me in doing this. Below is the code.. function save() { clientContext = new SP.ClientContext.get_current(); oWebsite = clientContext.get_web(); oList = clientContext.get_web().get_lists().getByTitle('MainList'); clientContext.load(oList); clientContext.executeQueryAsync(OnSucceeded, onQueryFailed); } function GetListItemValue(listName, fieldName) { var list = oWebsite.get_lists().getByTitle(listName); var eventValue = document.getElementById(fieldName).value; eventValue = eventValue.replace(",", ""); var camlQuery = new SP.CamlQuery(); var filterdata = '<view><query><where><eq><fieldref name="Title/"><value type="Text">' + myreqValue.trim() + '</value></fieldref></eq></where></query></view>'; camlQuery.set_viewXml(filterdata); listItems = list.getItems(camlQuery); clientContext.load(list); clientContext.load(listItems, 'Include(Id)'); clientContext.executeQueryAsync(Succeeded,Failed); } function OnSucceeded() { itemCreateInfo = new SP.ListItemCreationInformation(); oListItem = oList.addItem(itemCreateInfo); oListItem.set_item('Title', 'My New Title'); var deptItemLookupField = new SP.FieldLookupValue(); //Problem in below line...I was unable to get ID var getId = GetListItemValue("Listname1", "txtboxname1"); alert("ID" + getId); if (getId != undefined) { deptItemLookupField.set_lookupId(getId); } var getId12 = GetListItemValue("Listname12", "txtboxname12"); alert("ID" + getId12); if (getId12 != undefined) { deptItemLookupField.set_lookupId(getId12); } oListItem.update(); clientContext.executeQueryAsync(itemadded, itemFailed); } function itemadded() { alert('Item added successfully'); } function itemFailed(sender, args) { alert('Item added itemFailed' + args.get_message() + '\n' + args.get_stackTrace()); }
RajHi,
For this requirement, you will need to retrieve all the lists objects you want firstly, then execute the requests one by one to get the value of the Title column using CAML or
LINQ.
How to: Retrieve Lists Using JavaScript
http://msdn.microsoft.com/en-us/library/office/hh185009(v=office.14).aspx
About
retrieve list items:
http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx
You can use
Promise in your script to make your requests sequentially:
http://www.shillier.com/archive/2013/03/04/using-promises-with-the-javascript-client-object-model-in-sharepoint-2013.aspx
http://www.learningsharepoint.com/2013/08/13/using-deferred-and-promise-to-handle-async-calls-in-sharepoint-client-object-model/
Best regards
Patrick Liang
TechNet Community Support -
Retrieving multiple values from one column in SELECT statement
Hi,
I have a slight dilemma in that I'm trying to pull down all the values from a column from a select statement that includes some JOINS in it.
If I run the query at the SQL Plus prompt, it pulls back all the values/rows.
When I run the select (and prepared ) statement in my JSP, it only pulls back one of the 4 values I'm trying to retrieve.
e.g.
at the DB level :
SELECT role_name, CC_ID FROM votetbl a
INNER JOIN APPROVERS b ON
a.BUSVP = b.BUSVP AND
a.BRANCH = b.BRANCH
WHERE CC_ID = 1688this will return:
ROLE_NAME CC_ID
ops 1688
ops 1688
comply 1688
legal 1688
comply 1688
When run in my JSP, like so:
String primID3a = request.getParameter("primID");
Statement stmtovoter = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
String prepvotSQL = "SELECT role_name, CC_ID FROM votetbl a INNER JOIN APPROVERS b ON a.BUSVP = b.BUSVP AND " +
"a.BRANCH = b.BRANCH WHERE CC_ID = ?";
PreparedStatement prepvotstmt = connection.prepareStatement(prepvotSQL);
prepvotstmt.setString(1, primID3a);
ResultSet rest3 = prepvotstmt.executeQuery();
rest3.next();
String votecat = rest3.getString(1);
out.println("Vote category: "+votecat);I only get ops returned.
Do I need to run an enumerator? Or reqest.getParameterValues or use a while statement around the results set?
Any feedback and direction here is welcomed!
Thanks!Actually, I tried looping and still only get 1, but returned several times.
i.e.
PreparedStatement prepvotstmt = connection.prepareStatement(prepvotSQL);
prepvotstmt.setString(1, primID3a);
ResultSet rest3 = prepvotstmt.executeQuery();
rest3.next();
String votecat = rest3.getString(1);
while (rest3.next()) {
out.print("category roles "+votecat);
}then I get returned the following:
admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admin
like so.
Where as at the DB level I get
ROLE_NAME CC_ID
admin 1688
ops 1688
ops 1688
ops 1688
ops 1688
ops 1688
ops 1688
ops 1688
risk 1688
comply 1688
legal 1688
legal 1688
ops 1688
comply 1688
Maybe the while should go around the getString(1) designation? But I was thinking I'd tried that and gotten invalid cursor error
Something is definitely amiss, between the prepared statement in the servlet and the SELECT statement at the DB level.
I can totally hardcode the statement in the servlet or JSP and it will return one value potentially several times, but only one.
Other times, it will not return a value at all, even though one resides in the db.
Yet go to the DB/SQL Plus prompt and it returns perfectly. I can simply copy and paste the SELECT statement from the out.print line I made and it works like a champ in SQL Plus. Any ideas why the same exact thing cannot return the proper values within the servlet/JSP?
Yeeeeeeesh!!! : (
Message was edited by:
bpropes20 -
Calculating values from row to row with pure sql?
Hello,
I'm searching for a way to calculate values from row to row with pure sql. I need to create an amortisation table. How should it work:
Known values at start: (they can be derived with an ordinary sql-statement)
- redemption amount RA
- number of payment terms NT
- annuity P (is constant in every month)
- interest rate IR
What has to be calculated:
First row:
RA1 = RA - P
Z1 = (RA1 * (IR/100/12))
T1 = P - Z1
2nd row
RA2 = RA1 - T1
Z2 = (RA2 * (IR/100/12))
T2 = P - Z2
and so on until NT has reached.
It should look like
NT
P
Tn
Zn
RAn
1
372,17
262,9
109,27
22224,83
2
372,17
264,19
107,98
21961,93
3
372,17
265,49
106,68
21697,74
4
372,17
266,8
105,38
21432,25
5
372,17
268,11
104,06
21165,45
6
372,17
269,43
102,75
20897,34
7
372,17
270,75
101,42
20627,91
8
372,17
272,09
100,09
20357,16
9
372,17
273,42
98,75
20085,07
10
372,17
274,77
97,41
19811,65
11
372,17
276,12
96,06
19536,88
12
372,17
277,48
94,7
19260,76
13
372,17
278,84
93,33
18983,28
14
372,17
280,21
91,96
18704,44
15
372,17
281,59
90,59
18424,23
16
372,17
282,97
89,2
18142,64
17
372,17
284,36
87,81
17859,67
18
372,17
285,76
86,41
17575,31
19
372,17
287,17
85,01
17289,55
20
372,17
288,58
83,59
17002,38
21
372,17
290
82,18
16713,8
22
372,17
291,42
80,75
16423,8
23
372,17
292,86
79,32
16132,38
24
372,17
294,3
77,88
15839,52
25
372,17
295,74
76,43
15545,22
26
372,17
297,2
74,98
15249,48
27
372,17
298,66
73,52
14952,28
28
372,17
300,13
72,05
14653,62
29
372,17
301,6
70,57
14353,49
30
372,17
303,09
69,09
14051,89
31
372,17
304,58
67,6
13748,8
32
372,17
306,07
66,1
13444,22
33
372,17
307,58
64,6
13138,15
34
372,17
309,09
63,08
12830,57
35
372,17
310,61
61,56
12521,48
36
372,17
312,14
60,04
12210,87
37
372,17
313,67
58,5
11898,73
38
372,17
315,21
56,96
11585,06
39
372,17
316,76
55,41
11269,85
40
372,17
318,32
53,85
10953,09
41
372,17
319,89
52,29
10634,77
42
372,17
321,46
50,71
10314,88
43
372,17
323,04
49,13
9993,42
44
372,17
324,63
47,55
9670,38
45
372,17
326,22
45,95
9345,75
46
372,17
327,83
44,35
9019,53
47
372,17
329,44
42,73
8691,7
48
372,17
331,06
41,11
8362,26
I would appreciate every help and idea to solve the problem solely with sql.
Thanks and regards
CarstenIt's using Model Clause and / or Recursive With (sometimes maybe both)
Regards
Etbin
with
rec_proc(nt,i,ra,p,ir,z,t) as
(select nt,i,ra - p,p,ir,round((ra - p) * 0.01 * ir / 12,2),p - round((ra - p) * 0.01 * ir / 12,2)
from (select 48 nt,22597 ra,372.17 p,5.9 ir,0 z,0 t,1 i
from dual
union all
select nt,i + 1,ra - t,p,ir,round((ra - t) * 0.01 * ir / 12,2),p - round((ra - t) * 0.01 * ir / 12,2)
from rec_proc
where i < nt
select * from rec_proc
try to adjust initial values and rounding please
NT
I
RA
P
IR
Z
T
48
1
22224.83
372.17
5.9
109.27
262.9
48
2
21961.93
372.17
5.9
107.98
264.19
48
3
21697.74
372.17
5.9
106.68
265.49
48
4
21432.25
372.17
5.9
105.38
266.79
48
5
21165.46
372.17
5.9
104.06
268.11
48
6
20897.35
372.17
5.9
102.75
269.42
48
7
20627.93
372.17
5.9
101.42
270.75
48
8
20357.18
372.17
5.9
100.09
272.08
48
9
20085.1
372.17
5.9
98.75
273.42
48
10
19811.68
372.17
5.9
97.41
274.76
48
11
19536.92
372.17
5.9
96.06
276.11
48
12
19260.81
372.17
5.9
94.7
277.47
48
13
18983.34
372.17
5.9
93.33
278.84
48
14
18704.5
372.17
5.9
91.96
280.21
48
15
18424.29
372.17
5.9
90.59
281.58
48
16
18142.71
372.17
5.9
89.2
282.97
48
17
17859.74
372.17
5.9
87.81
284.36
48
18
17575.38
372.17
5.9
86.41
285.76
48
19
17289.62
372.17
5.9
85.01
287.16
48
20
17002.46
372.17
5.9
83.6
288.57
48
21
16713.89
372.17
5.9
82.18
289.99
48
22
16423.9
372.17
5.9
80.75
291.42
48
23
16132.48
372.17
5.9
79.32
292.85
48
24
15839.63
372.17
5.9
77.88
294.29
48
25
15545.34
372.17
5.9
76.43
295.74
48
26
15249.6
372.17
5.9
74.98
297.19
48
27
14952.41
372.17
5.9
73.52
298.65
48
28
14653.76
372.17
5.9
72.05
300.12
48
29
14353.64
372.17
5.9
70.57
301.6
48
30 -
Expanding table: Calculating difference to value from previous row
Hi there,
I am a complete newbie to LiveCycle Designer (ES2) and have created below document with an expanding table.
Shared Files - Acrobat.com
My aim is to make the form user friendly by adding a calculation in the field "Twist" which calculates the difference from the current row to the previous row.
I have no idea about Java Script, I am afraid, and also don't know if this is possible at all so it's probably a bad idea after all.
The reason for setting it up as an expanding table is so that the form can be used for all 32 instances the form would be used for (they would all require different amount of rows altogether).
The calculation would start in row 2 (Checklist.Table1), take the twist value entered in row 2 and calculate the difference to the twist value entered in row 1.
Then in row 3, it would calculate the difference between twist value in row 3 to row 2 etc.
So subtract value of field in rown with value in rown-1 or something in this direction.
Is there anyone at all who could help me with this at all?
I'd be very grateful for any advice you could give me.
Thanks a lot!
MathildaNot sure what happened with the formatting there, try this;
if (Row1.index > 0 && !Row1.resolveNode("NumericField4[0]").isNull)
var prevTwist = Table1.resolveNode("Row1[" + (Row1.index - 1) + "].NumericField4[0]").rawValue
var result = Math.abs(3000 / (Row1.resolveNode("NumericField4[0]").rawValue - prevTwist));
this.rawValue = result;
else
this.rawValue = ""; -
How to return a single datetime from multiple rows of MAX(value) in DAX
Hi
I have a Results table with ResultTime, Balance, Equity which is updated with a new row every 5 minutes. I've used SUMX to find opening and closing balances and it has worked so far.
Res_OpeningBalance:=SUMX(TOPN(1,Results,Results[ResultTime],1),[Balance])
Res_ClosingBalance:=SUMX(TOPN(1,Results,Results[ResultTime],0),[Balance])
But when I tried it with dates, the whole thing fell apart.
Res_MaxBalance_Date:=SUMX(TOPN(1,Results,Results[Balance],0),[ResultTime])
Since the highest Balance is likely to be represented through many rows due to it lasting more than 5 minutes, ResultTime (which is unique to each row) is summed up and returns messed up dates well into the future. How to return only one date (first or last
datetime) from the rows where Balance is at max?
I tried a TOPN of TOPN, but Excel was not amused.
=SUMX(TOPN(1,Results,Results[Balance],0),TOPN(1,Results,Results[ResultTime],0))
TIA!
Re
DennisI still don't understand RANKX, but I figured it out anyway. I get the correct data by using:
Res_MaxBalance:=MAX(Results[Balance])
Res_MaxBalanceDate:=CALCULATE(MAX(Results[ResultTime]),FILTER(Results, Results[Balance]=MAX(Results[Balance])))
Res_MinBalance:=MIN(Results[Balance])
Res_MinBalanceDate:=CALCULATE(MAX(Results[ResultTime]),FILTER(Results, Results[Balance]=MIN(Results[Balance])))
Res_MaxEquity:=MAX(Results[Equity])
Res_MaxEquityDate:=CALCULATE(MAX(Results[ResultTime]),FILTER(Results, Results[Equity]=MAX(Results[Equity])))
Res_MinEquity:=MIN(Results[Equity])
Res_MinEquityDate:=CALCULATE(MAX(Results[ResultTime]),FILTER(Results, Results[Equity]=MIN(Results[Equity])))
Re
D -
Custom row-fetch and how to get column values from specific row of report
Hi -- I have a case where a table's primary key has more than 3 columns. My report on the
table has links that send the user to a single-row DML form, but of course the automatic
fetch won't work because 1) I can't set more than 3 item values in the link and 2) the
auto fetch only handles 2 PK columns.
1)
I have written a custom fetch (not sure it's the most elegant, see second question) that is working
for 3 or few PK columns (it references the 1-3 item values set in the link), but when there are
more than 3, I don't know how to get the remaining PK column values for the specific row that was
selected in the report. How can I access that row's report column values? I'll be doing it from the
form page, not the report page. (I think... unless you have another suggestion.)
2)
My custom fetch... I just worked something out on my own, having no idea how this is typically
done. For each dependent item (database column) in the form, I have a source of PL/SQL
function that queries the table for the column in question, using the primary key values. It works
beautifully, though is just a touch slow on my prototype table, which has 21 columns. Is there
a way to manually construct the fetch statement once for the whole form, and have APEX be smart
about what items get what
return values, so that I don't have to write PL/SQL for every item? Because my query data sources
are sometimes in remote databases, I have to write manual fetch and dml anyway. Just would like
to streamline the process.
Thanks,
CarolHI Andy -- Well, I'd love it if this worked, but I'm unsure how to implement it.
It seems I can't put this process in the results page (the page w/ the link, that has multiple report rows), because the link for the row will completely bypass any after-submit processes, won't it? I've tried this in other conditions; I thought the link went directly to the linked-to page.
And, from the test of your suggestion that I've tried, it's not working in the form that allows a single row edit. I tried putting this manually-created fetch into a before header process, and it seems to do nothing (even with a hard-coded PK value, just to test it out). In addition, I'm not sure how, from this page, the process could identify the correct PK values from the report page, unless it can know something about the row that was selected by clicking on the link. It could work if all the PK columns in my edit form could be set by the report link, but sometimes I have up to 5 pk columns.
Maybe part of the problem is something to do with the source type I have for each of the form items. With my first manual fetch process, they were all pl/sql functions. Not sure what would be appropriate if I can somehow do this with a single (page level?) process.
Maybe I'm making this too hard?
Thanks,
Carol
Maybe you are looking for
-
Inserting record in table on selection of another table
Hi All, I have a table with multiple line items, and i have one insert button. If i select line items in first table i want to create new records in 2nd table that is new structure( some values are same ). Here problem is i am getting all records in
-
How to DEBUG a function module running in background mode? Please help!
Hi Experts, I am calling a function module in my ABAP code in background module using the following syntax: CALL FUNCTION 'YBBC2_CREATE_SNAPSHOT' IN BACKGROUND TASK TABLES itab_std_format_inv = itab_std_format_inv
-
IDOC_INPUT_INVOIC_MRM URGENT ERROR plz help
hello expert im using IDOC_INPUT_INVOIC_MRM to create Idoc. im facing a problem. the docnum in EDIDC and EDIDD is not generated. it always equal to 00000000000000 so the program cant create the idoc. do you have any idea plzz, it s urgent im facing t
-
In my (swedish) course literature I am currently supposed to write an Applet that follows the actions of the window when it is resized . The point is to learn ComponentListener and making it runnable to avoid flickering. the applet is supposed to loo
-
FRM-40010 cannot read from maninda.fmx
My form works once when I run it from a new startup of my fmx file however when i use the service or run it again i get the above error from the run form on the web and HTML error on oracle forms developer as follows: <html> <head> ORACLE FORMS.</hea