Average of 2 columns for an insert
Hello I have two tables and want to get the average of every value within a row( Not AVG- function) e.g. . I want to write an insert table "Messdaten_vorbereitung" and extract the rows from table "STAGE_DM_MESSDATEN". So, i want to get
(air_temp_port_der +air_temp_stb_der)/2 for column AIR_TEMP_AVG in table "Messdaten_vorbereitung"
create table STAGE_DM_MESSDATEN
SYSTEM_DATE_DER DATE,
SYSTEM_TIME_DER VARCHAR(8),
AIR_TEMP_PORT BINARY_DOUBLE,
AIR_TEMP_STB BINARY_DOUBLE,
TRUE_WD_PORT_DER BINARY_DOUBLE,
TRUE_WD_STB_DER BINARY_DOUBLE,
TRUE_WS_PORT BINARY_DOUBLE,
TRUE_WS_STB BINARY_DOUBLE,
HUMIDITY_PORT BINARY_DOUBLE,
HUMIDITY_STB BINARY_DOUBLE,
WATER_TEMP_PORT BINARY_DOUBLE,
WATER_TEMP_STB BINARY_DOUBLE);
create table Messdaten_vorbereitung
SYSTEM_DATE_DER DATE,
SYSTEM_TIME_DER VARCHAR(8),
AIR_TEMP_AVG BINARY_DOUBLE,
TRUE_WD_AVG BINARY_DOUBLE,
TRUE_WS_AVG BINARY_DOUBLE,
HUMIDITY_AVG BINARY_DOUBLE,
WATER_TEMP_AVG BINARY_DOUBLE);
How can I do it?
Thanks a lot
I'm a historian by training and chary about straying into the realm of high maths but wouldn't this work?
INSERT INTO Messdaten_vorbereitung
SELECT system_date_der ,
system_time_der,
(air_temp_port+air_temp_stb)/2,
(true_wd_port_der+true_wd_stb_der)/2,
(true_wd_port+true_wd_stb)/2,
(true_ws_port+true_ws_stb)/2,
(humidity_port+humidity_stb)/2,
(water_temp_port+water_temp_stb)/2
FROM stage_dm_messdaten
/Cheers, APC
Similar Messages
-
SQL report to get average amount of time for helpdesk closures Pin
Hi, I've been asked to write a report which lists the average time it takes for a helpdesk job to be closed. There isn't a closed date as such, the table column is simply an audit date/time which can be for various tasks.
I need to use this column along with another which is an ID of the action. For example:
User TaskID Task AuditDatetime
Bob 2 Opens job 1/8/2014 11:14:29
Bob 5 Closes job 2/8/2014 10:12:26
Joe 2 Opens job 2/8/2014 11:01:45
Bob 5 Closes job 3/8/2014 11:44:22
My SQL is very rusty, I'm sure the report is technically possible but I can't for the life of me figure out what the SQL is.
I'm aware of the SQL AVG function and also know I may need to GROUP BY the user. I'm thinking some kind of CASE statement perhaps but again I can't think of the SQL to achieve this...
Can anybody please help?DECLARE @helpDesk TABLE (JobID INT, userName varchar(10), TaskID INT, Task VARCHAR(20), AuditDatetime DATETIME)
INSERT INTO @helpDesk (JobID, userName, TaskID, Task, AuditDatetime)
VALUES
(17, 'Bob', 2, 'Opens job', '8/1/2014 11:14:29'),
(17, 'Bob', 5, 'Closes job', '8/2/2014 10:12:26'),
(22, 'Joe', 2, 'Opens job', '8/2/2014 11:01:45'),
(22, 'Bob', 5, 'Closes job', '8/3/2014 11:44:22'),
(25, 'Bob', 1, 'Opens job', '8/4/2014 11:40:22'),
(25, 'Joe', 3, 'Assigned job', '8/5/2014 11:47:22'),
(25, 'Joe', 5, 'Closes job', '8/5/2014 11:49:22')
SELECT *, DATEDIFF(minute,h2.AuditDatetime,h.AuditDatetime)/60.0 AS hours
FROM @helpDesk h
INNER JOIN @helpDesk h2
ON h.jobID = h2.jobID
AND h2.task = 'opens job '
WHERE h.task = 'Closes Job'
As far as open Jobs go, you could flip it around, like this:
DECLARE @helpDesk TABLE (JobID INT, userName varchar(10), TaskID INT, Task VARCHAR(20), AuditDatetime DATETIME)
INSERT INTO @helpDesk (JobID, userName, TaskID, Task, AuditDatetime)
VALUES
(17, 'Bob', 2, 'Opens job', '8/1/2014 11:14:29'),
(17, 'Bob', 5, 'Closes job', '8/2/2014 10:12:26'),
(22, 'Joe', 2, 'Opens job', '8/2/2014 11:01:45'),
(22, 'Bob', 5, 'Closes job', '8/3/2014 11:44:22'),
(25, 'Bob', 1, 'Opens job', '8/4/2014 11:40:22'),
(25, 'Joe', 3, 'Assigned job', '8/5/2014 11:47:22'),
(25, 'Joe', 5, 'Closes job', '8/5/2014 11:49:22'),
(26, 'Joe', 5, 'Opens job', '8/5/2014 11:49:22')
SELECT *, DATEDIFF(minute,h.AuditDatetime,COALESCE(h2.AuditDatetime,GETDATE()))/60.0 AS hours
FROM @helpDesk h
LEFT OUTER JOIN @helpDesk h2
ON h.jobID = h2.jobID
AND h2.task = 'Closes job '
WHERE h.task = 'Opens Job'
and coalesce the current date in for a close date. -
Received this error (The workflow could not update the item, possibly because one or more columns for the item require a different type of information.) recently on a workflow that was
working fine and no changes were made to the workflow.
I have tried a few suggestions, i.e. adding a pause before any ‘Update’ action (which didn’t help because the workflow past this action without incident); checked the data type being written
to the fields (the correct data types are being written); and we even checked the list schema to ensure the list names and the internal names are aligned (they
are), but we still cannot figure out why the workflow is still throwing this error.
We located the area within the workflow step where it is failing and we inserted a logging action to determine if the workflow would execute the logging action but it did not, but wrote the same error message.
The workflow is a Reusable Approval workflow designed in SharePoint Designer 2010 and attached to a content type.
The form associated with the list was modified in InfoPath 2010.
Approvers would provide their approval in the InfoPath form which is then read by the workflow.
Side note - items created after the workflow throws this Unknown Error some seem to be working fine.
We have deleted the item in question and re-added it with no effect.
Based on what we were able to determine there don’t seem to be any consistency with how this issue is behaving.
Any suggestions on how to further investigate this issue in order to find the root cause would be greatly appreciated?
CheersHi,
I understand that the reusable workflow doesn’t work properly now. Have you tried to remove the Update list item action to see whether the workflow can run without issue?
If the workflow runs perfectly when the Update list item action is removed, then you need to check whether there are errors in the update action. Check whether the values have been changed.
Thanks,
Entan Ming
Entan Ming
TechNet Community Support -
Average of the column in ALV report
Hi,
I am working on an ALV report and for one of the column, i am calculating the average with fieldcatalog property do_sum = 'C'.
I am sorting the output table for 2 fields and whenever I am expanding/compressing the sorted fields the average of the column is changing. Please let me know how do I get this average calculated constant. It should not change when the user collapses/expands on the sorted field.
Regards
RashmiThe same question has been asked in this thread:
Compute average of a report column
I have offered a solution but as I've said it's not great but it may meet your needs.
Or another forum user may review and be able to suggest a better solution.
Does the average need to be part of the report?
Could you calculate it and display it within a page item below the report instead? -
Average of a column in Normal Report
Hi
I am using a simple report. I want to display average of a column on the bottom of the report. I am not able to
find any option for it. how to show average of a cloumn on simple report.
Please help me.
Thanks
PKThe same question has been asked in this thread:
Compute average of a report column
I have offered a solution but as I've said it's not great but it may meet your needs.
Or another forum user may review and be able to suggest a better solution.
Does the average need to be part of the report?
Could you calculate it and display it within a page item below the report instead? -
How to Design a Page for Both Insertion and Updation
Hi,
I have Page where I need to populate a table from Standard PO/AP table and once the save is clicked on the table,
the data shoudl be inserted in custoim table.
Ex: Ui table wil have 3 columns and say 5 rows
- PO#
- Line#
- Amount for 'X' purpose
where PO# and Invoice# is populated and Amount is empty
User will enter value in Amount column in all 5 rows and click on Save button.
Now these 5 rows with 3 columns should be inserted into the custom table (PO#, Line# and Amount)
How Can I design Model Objects for such a requirement?
Thanks,
KamathYou should create an EO on your custom table and a VO on your EO. As you insert records in the VO, corresponding rows are created as EO rows and when you commit (getOADBTransaction().commit()) in the AM everything would get committed to the DB.
As far as subject goes of having a common page, everytime you can execute the VO with the bind parameters and check whether a row exists. If it does exist then update the VO Row (I expect the master record to be unique row). Otherwise create a new Row for the master and then correspondingly for the details row.
Do let me know in case you need additional information.
Regards
Sumit -
KMTL - How to add Column for OVER DUE DAYS in report
Dear Concern,
We are Microsoft Dynamics NAV 2013 users, We want a little change on Reminder Report (In report there is due date we inserted column for OVER DUE DAYS right side to Due Date column in we required Expression of which type of formula that
shows us the Over Due Days for particular.
Please every one confirm or suggest for this error.
Thanks & regards,
Laxman SonarHi Laxman Sonar,
Per my understanding that you have an date field(Due Date) in the report and now you want to get the over due days based on this field and display at right of the date field in the report, right?
I have tested on my local environment that we have two method to do this, one is to add the datediff functon in the query to get the overdue days and another method is to using expression in the report.
Details information below for your reference:
Method one:
Modify the query as below to get the new field(OverDue Days):
SELECT DueDate, DATEDIFF(day, DueDate, GETDATE()) AS OverDueDays
FROM tableName
Method Two:
Add an calculated fields and then add the expression below to get the value for this field or just add expression directly in the new field:
=Datediff("d",Fields!DueDate.Value,Today())
If your problem still exists, please try to provide us some sample date and more details information about your requirements.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support -
Year Total of Gross Margin % Plan in the column for months
Dear Experts,
I have designed a query with the KFs "Sale/Retail, Gross Margin% and Sales/Cost" in the rows and months in the column. I have put "Gross Margin % and Sales/Retail" as input ready and the Sales At Cost is getting calculated with the formula applied over Gross Margin %.
So if i am enetring 1000 for Sales/Retail in Jan month with Gross Margin % as 10%. the value of Sales/Cost is getting calculating correctly as 900.
Now i want to add a total column which will show the year total result of my planning for all months.
Here i am facing the problem.
I have inserted a Formula (named as "Year"), and put the formula to add all the months.
Suppose now i have entered 1000 Sales/Retail and Gross Margin % as 10% in Jan and Feb month.
So now the total figures in the Year column is correct for the Sale/Retail=2000 as it is getting added for every month, but the Gross Margin % is not correct as it is also getting added to 20%. And because of this the Sales/Cost is also wrongly calculated.
The Gross Margin % should be avearge of all months.
Can somebody help me to resolve. Any better idea to insert total column for the months will also help me.
Warm Regards
AbhishekHi Gokul,
I have resolved the thing. Actually. When i use the Tab "Calculations" in the Query Designer. The effect reflects in the result and Overall result section.
But i wanted to correct the Data Input section with the Year total. So i have put the formula in the cells and used collision functionality to avoid the formula collision. So this resolved the problem.
Thanks.
Warm Regards
Abhishek
Edited by: Abhi Goel on Jun 3, 2010 1:29 PM -
Need help identifying the application responsible for an insert...
Hi,
I'm a MSSQL guy and Oracle is still a bit mysterious to me. I'm looking for some assistance tracking down the application in an environment which is responsible for particular inserts.
For example, suppose I have 10 different programs running and inserting values to a DB. I need to know which one of them inserts a "0" in a particular column.
I found a trigger which will tell me the user, unfortunately these programs use a shared credential so that doesn't help me.... here's what I've got:
CREATE OR REPLACE TRIGGER check_for_zero_insert
AFTER INSERT
ON DATA_TABLE_0001
FOR EACH ROW
DECLARE
v_username varchar2(10);
BEGIN
-- Find username of person performing the INSERT into the table
SELECT user INTO v_username
FROM dual;
-- Insert record into audit table
INSERT INTO audit_table
( samplevalue
sampletime,
username )
VALUES
( :sampletime,
:samplevalue
v_username );
END;
But again, username won't help me, I need the originating process if at all possible (either an executable name, PID, or something to identify the specific application on the other side.)use this in your trigger
select sys_context('USERENV','OS_USER') ||'-' ||user into v_username from dual;
You might need to increase the v_username data type length.
Thanks,
GPU -
ORA-38101: Invalid column in the INSERT VALUES Clause: "acn"
Hi,
Oracle version :
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
Funny issue,
MERGE INTO tfc cb1
USING (SELECT 5351 fs,
1 cs
FROM DUAL) dual1
ON (cb1.fs = dual1.fs
AND cb1.asgn_cs = dual1.cs)
WHEN MATCHED
THEN
UPDATE
SET cb1.acn = '145' ,
cb1.cbs = (SELECT ta.as
FROM tac ta
WHERE ta.acn = '145'
AND ta.ent = 2),
cb1.bfs = 3 ,
cb1.efd = '28-OCT-09' ,
cb1.uui = 'A' ,
cb1.ut = sysdate
WHERE cb1.fs = 5351
AND cb1.asgn_cs = 1
WHEN NOT MATCHED
THEN
INSERT
(cb1.fund_cbs,
cb1.asgn_cs,
cb1.cbs,
cb1.fs,
cb1.bfs,
cb1.acn,
cb1.efd,
cb1.cre_usr_id,
cb1.uui
VALUES
(tfc.NEXTVAL,
dual1.cs,
(SELECT ta.as
FROM tac ta
WHERE ta.acn = '145'
AND ta.ent = 2),
dual1.fs,
3,
'145',
'28-OCT-09',
'A',
'A'
);When i try to run this , get
Error report:
SQL Error: ORA-38101: Invalid column in the INSERT VALUES Clause: "acn"
38101. 00000 - "Invalid column in the INSERT VALUES Clause: %s"
*Cause: INSERT VALUES clause refers to the destination table columns
*Action:
Now, when I try n remove the alias name from the insert clause, i.e.
MERGE INTO tfc cb1
USING (SELECT 5351 fs,
1 cs
FROM DUAL) dual1
ON (cb1.fs = dual1.fs
AND cb1.asgn_cs = dual1.cs)
WHEN MATCHED
THEN
UPDATE
SET cb1.acn = '145' ,
cb1.cbs = (SELECT ta.as
FROM tac ta
WHERE ta.acn = '145'
AND ta.ent = 2),
cb1.bfs = 3 ,
cb1.efd = '28-OCT-09' ,
cb1.uui = 'A' ,
cb1.ut = sysdate
WHERE cb1.fs = 5351
AND cb1.asgn_cs = 1
WHEN NOT MATCHED
THEN
INSERT
(cb1.fund_cbs,
cb1.asgn_cs,
cb1.cbs,
cb1.fs,
cb1.bfs,
cb1.acn,
cb1.efd,
cb1.cre_usr_id,
cb1.uui
VALUES
(tfc.NEXTVAL,
dual1.cs,
(SELECT as
FROM tac
WHERE acn = '145' -------- remove alias from here i.e. 'ta'
AND ent = 2),
dual1.fs,
3,
'145',
'28-OCT-09',
'A',
'A'
);The above statement fine.
Edited by: user8650395 on Mar 12, 2010 6:10 AM
Edited by: user8650395 on Mar 12, 2010 6:19 AMHi,
Nice formatting!
The first value in the INSERT clause looks suspicious:
MERGE INTO tfc cb1
INSERT
(cb1.fund_cbs,
cb1.asgn_cs,
cb1.cbs,
cb1.fs,
cb1.bfs,
cb1.acn,
cb1.efd,
cb1.cre_usr_id,
cb1.uui
VALUES
(tfc.NEXTVAL, ...If tfc is a table name, then it can't be a sequnece name.
Perhaps you meant something like
... VALUES
(tfc_id_seq.NEXTVAL, ...I hope that solves the problem.
If not, post a little sample data (CREATE TABLE and INSERT statements) for the tables as they exist before the MERGE.
Edited by: Frank Kulash on Mar 12, 2010 9:34 AM -
Multiple columns for more than one record?
Crystal Reports Xi
I have a list of addresses, etc. with attached route numbers. If an address has 2 different route numbers, it will appear as two records. Is there a way that I can list the address once, and have the route numbers just grow to more columns?
Example - Change this...
ADDRESS ROUTE
100 Main St. 1234
100 Main St. 1235
To This...
100 Main St. 1234 1235
Note: An address may have one route number attached, or several route numbers attached.
I tried playing around with the multiple columns, etc, but it kept on having everything in the section become multiple columns, etc. Any help is appreciated.multiple columns only work in detail section.
place your address without the route in the 1st details
then insert a 2nd details and place the route in the details then select multiple columns for that details section.
then underlay the first detail section and it should line up. -
hi all
I am in the process of designing tables for our new system. We want to prevent duplicated rows from being inserted into tables. For this purpose,i want to utilize IOTs instead of heap tables cause almost all the columns of our tables are primary keys.
After talking to our application desigers, i was told that these table will have dense inserts at every monment.
I dont't know if IOT suitable for this sitution becase i have googled alot that there are sayings that IOT only suitable for static tables.
Any input will be appreciated.When to use IOTs:
1. "An IOT is structured almost identically to a normal index. They are best used for relatively static lookup tables, that are always accessed through primary keys. If the mass update is an infrequent thing, and the table is mostly used for lookup, then I would likely go ahead and use an IOT and take the slow update performance occasionally. However, if mass updates are a frequent occurence, then this is probably not a good candidate for an IOT."
By John Spencer
Source:Re: IOT slower to update
2. When the table basically consists of its primary kay and not much else, and when we access the table only through its primary key. The canonical example is a code lookup table, where we have two columns CODE and MEANING.
By APC
Source:When we Use Index Organized Table(IOT)?
3. "IOT with 1 million inserts - maybe that works for you performance-wise, but kind of goes against the idea of IOT (better for updates, not as good for frequent inserts).
What about MVs? Use the main/frequently used columns. With 1 million inserts a day (or about 694 inserts per minute), what human in your organization is going to be able to keep up with that rate of change? "
By SteveC
Source:http://dbaforums.org/oracle/index.php?showtopic=11146
4. So, before reaching to any conclusion, i will read following too:
a)http://www.oracle.com/technology/products/oracle9i/pdf/iot_twp.pdf
b)http://www.oracle.com/technology/products/oracle9i/datasheets/iots/iot_ds.html
c)http://www.orafaq.com/forum/t/145827/0/
d)http://www.peled.com/white_papers/iot.pdf
HTH
Girish Sharma
Edited by: Girish Sharma on Dec 9, 2009 11:09 AM
3rd Point added.. -
Initialize sub sequence column values on insert?
I asked this on stack overflow, but it was recommended that I also ask here.
http://stackoverflow.com/questions/12982875/initialize-sub-sequence-column-values-on-insert-oracle
I would like my table to sequence its "order by" column based on it's TEMPLATE_ID. I would like this to happen on insert (via an insert trigger, probably). For example, if I run the following inserts, I should get the following table values.
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (3, 1)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (4, 2)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (5, 2)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (6, 2)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (7, 2)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (8, 3)
ID TEMPLATE_ID ORDER_BY
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
6 2 3
7 2 4
8 3 1I first tried to create this trigger, but it gives me an error when I insert.
create or replace
trigger TEMPLATE_ATTRIBUTES_AF_INS_TRIG
after insert on TEMPLATE_ATTRIBUTES
for each row
begin
if :NEW.ORDER_BY is null then
update TEMPLATE_ATTRIBUTES
set ORDER_BY = (select coalesce(MAX(ta.ORDER_BY), 0) + 1 from TEMPLATE_ATTRIBUTES ta where ta.TEMPLATE_ID = :NEW.TEMPLATE_ID)
where ID = :NEW.ID;
end if;
end;The error it gives me is: "table TEMPLATE_ATTRIBUTES is mutating, trigger/function may not see it"
So I need a different way to build this trigger. And I also need it to "thread safe" so that if these two inserts occur on different sessions at the same time, then the resulting records will still get different "ORDER_BY" values:
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1)
Edit:
I tried the common work around for the "table is mutating, trigger/function may not see it" and the work around "worked" but it was not "thread safe." I tried to add locking but it gave me another error on insert
create or replace package state_pkg
as
type ridArray is table of rowid index by binary_integer;
newRows ridArray;
empty ridArray;
end;
create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TB4
before insert on TEMPLATE_ATTRIBUTES
begin
state_pkg.newRows := state_pkg.empty;
end;
create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TAF1
after insert on TEMPLATE_ATTRIBUTES for each row
begin
if :NEW.ORDER_BY is null then
state_pkg.newRows( state_pkg.newRows.count+1 ) := :new.rowid;
end if;
end;
create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2
after insert on TEMPLATE_ATTRIBUTES
declare
v_request number;
v_lockhandle varchar2(200);
begin
dbms_lock.allocate_unique('TEMPLATE_ATTRIBUTES_ORDER_BY_lock', v_lockhandle);
while v_request <> 0 loop
v_request:= dbms_lock.request(v_lockhandle, dbms_lock.x_mode);
end loop;
begin
for i in 1 .. state_pkg.newRows.count loop
update TEMPLATE_ATTRIBUTES
set ORDER_BY = (select coalesce(MAX(q.ORDER_BY), 0) + 1 from TEMPLATE_ATTRIBUTES q where q.TEMPLATE_ID = (select q2.TEMPLATE_ID from TEMPLATE_ATTRIBUTES q2 where q2.rowid = state_pkg.newRows(i)))
where rowid = state_pkg.newRows(i);
end loop;
v_request:= dbms_lock.release(v_lockhandle);
EXCEPTION WHEN OTHERS THEN
v_request:= dbms_lock.release(v_lockhandle);
raise;
end;
end;This gives me:
ORA-04092: cannot COMMIT in a trigger ORA-06512: at "SYS.DBMS_LOCK", line 250 ORA-06512: at "TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2", line 5 ORA-04088: error during execution of trigger 'TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2' ORA-06512
Edit 2: The ORDER_BY column must be an updateable column. ID actually uses a sequence and before insert trigger to set its values. I thought I was simplifying my question when I included it in the insert examples, but that was incorrect. ORDER_BY's initial value is not really related to ID, but rather to what order the records are inserted. But ID is sequenced so you can use that if it helps.Check here below:
create table TEMPLATE_ATTRIBUTES
( ID INTEGER
, TEMPLATE_ID INTEGER
, ORDER_BY INTEGER
CREATE OR REPLACE TRIGGER templ_attr_bf_ins_trg
BEFORE INSERT
ON template_attributes
FOR EACH ROW
BEGIN
IF :new.order_by IS NULL
THEN
SELECT NVL (MAX (ta.order_by), 0) + 1
INTO :new.order_by
FROM template_attributes ta
WHERE ta.template_id = :new.template_id;
END IF;
END;
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (3, 1);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (4, 2);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (5, 2);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (6, 2);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (7, 2);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (8, 3);
SELECT * FROM TEMPLATE_ATTRIBUTES;
Output:
ID TEMPLATE_ID ORDER_BY
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
6 2 3
7 2 4
8 3 1
{code}
Let me also comment that I don't like this solution. It might conflict with multiuser access.
If you just need the column to order the table you can use a sequence and then order you table by template_id, order_by (generated by a sequence).
In this way you will not have a problem with multiuser access. Do you care that order_by column is not starting from 1 for each template_id and it has "holes" in the sequence for that template_id?
Regards.
Al
Edited by: Alberto Faenza on Oct 22, 2012 5:11 PM -
Hi, How do I get an average of a column without including the zeros ?
Im using Numbers and I want to get an average of the column but I can't seem to take the Zeros out of the equation.
Can someone please help?
Please.This example was strictly greater than zero. if you want non-zero values, then this may work for you:
=AVERAGEIF(A1:A8, "<>0") -
Check average growth (by week for example) for the biggest tables
Hello friends,
I have the list of the biggest tables,
but i need to check average growth (by week for example) for the biggest tables.
Is it possible somehow ?
Thanks in advance,Hi Jordy,
Call DB02. Then go to Space -> Segments -> Detailed Analysis -> Select the tablename on the list by double click -> At the bottom table click on History -> Click on Weeks tab -> Find the value under Chg.Size column
Best regards,
Orkun Gedik
Maybe you are looking for
-
Pls anybody tel me what is self life / ageing report in mm
hi all, i have to develop self life ageing report. pls anybody tel me what is self life / ageing report in mm. pls send me template and code. regards vikas
-
Missing or wrong file type icons
Got my new Retina iMac this week (running OS X 10.10 of course) and went through and downloaded/installed all my lovely programs but now some of the file type icons are showing up as awful exec type file icons (see below). All the .indd files were cr
-
Hi all, I have a full Photoshop webpage layout file with several layers – and I need to extract parts of it to use on the website. I do know a little bit about slices – but I would prefer to not use that now. Rather I was thinking of saving a tiff fi
-
What is the reason for this Exception
oracle.jdbc.driver.T4CCallableStatement. any suggestions would be appreciated. rgds Parameswaran
-
Mac Word 2008 Cut-And-Paste broken with DW CS3
The title pretty much says it all - something is failing in the process of cutting text from a MS Word 2008 (Mac) document into Dreamweaver CS3. Nothing gets transferred. I can cut text from Word and paste into other text editors (BBEdit, TextMate, T