SQL Help Needed: Split & Replace - Update Column Vale
Hello experts,
I would like to seek for your expertise on how to update part of the column's value for many rows.
Let say, I have a table (table1) with 2 columns (col1 & col2)
col1 col2
100 abc.123
200 abc.456
300 abc.789
and i need to update abc to efg for col2 to become like
col1 col2
100 efg.123
200 efg.456
300 efg.789
any clue on how should the query looks like ?
pls advise, many thanks.
For your given example, Michael's solution will work, however it may have problems if you had abc more than one time in a row.
For example, could you have a value like abc.123.abc in a row? If so, would you want to update it to efg.123.efg or to efg.123.abc?
If you want the firs, then Michael's is correct, if you want the second, then you would need something more like:
UPDATE table1
SET col2 = 'abc'||SUBSTR(col2, 4)
WHERE SUBSTR(col2, 1, 3) = 'abc'John
Similar Messages
-
Help needed. Just updated my I phone 4 and lost all my notes, and no I didn't put them in the I cloud. Please help. Need those notes!
You could always check to make sure itunes is updated to 10.7 but im sure gdgmacdude is
right.
thanks
gdgmacdude
Hey dude
are there anymore hardware failure errors u know of
im kinda a novice apple man and could use all the help i can get
capp -
SQL Help -- Need help with pivoting the columns to rows
I have a requierement to split the columns into multiple rows. For example:
EMP_DEPT
rowid empid1 ename1 dept1 empid2 ename2 dep2 empid2 ename2 dep3 empid4 ename4 dept4
100001 1 'SCOTT' 10 2 'DAVE' 20 3 'MILLER' 10 4 SMITH 20
100002 1 'SCOTT' 10 2 'DAVE' 20 3 'MILLER' 20
Note: EMP_DEPT may not always have all the 4 employee info populated for example in row 2 only 3 employees info is there
I need to convert it and insert into EMPLOYEE table as follows:
EMPLOYEE
empid ename dept
1 SCOTT 10
2 DAVE 20
3 MILLER 10
4 SMITH 20
1 SCOTT 10
2 DAVE 20
3 MILLER 20
Thanks
KevFrank Thank You for your response.
I am on oracle 10gR2.
Posting some sample DDL and data here as requested:
CREATE TABLE EMP
PK NUMBER(10),
EMP_NAME1 VARCHAR2(100 BYTE),
EMP_ID1 NUMBER(10),
EMP_NAME2 VARCHAR2(100 BYTE),
EMP_ID2 NUMBER(10),
DEPT_NAME1 VARCHAR2(200 BYTE),
DEPT_ID1 NUMBER(10),
DEPT_NAME2 VARCHAR2(200 BYTE),
DEPT_ID2 NUMBER(10)
CREATE TABLE EMP_DEPT
( PK NUMBER(10),
ENTY_TYPE VARCHAR2(100),
ENTY_NAME VARCHAR2(100),
ENTY_ID NUMBER(10)
Insert into EMP
(PK, EMP_NAME1, EMP_ID1, EMP_NAME2, EMP_ID2, DEPT_NAME1, DEPT_ID1, DEPT_NAME2, DEPT_ID2)
Values
(1, 'SCOTT', 10001, 'FRANK', 10002,
'MARKETING', 10, 'ACCOUNTING', 20);
Insert into EMP
(PK, EMP_NAME1, EMP_ID1, EMP_NAME2, EMP_ID2, DEPT_NAME1, DEPT_ID1)
Values
(2, 'SCOTT1', 10003, 'FRANK1', 10004,
'MARKETING1', 30);
COMMIT;
SELECT
FROM
EMP;
PK EMP_NAME1 EMP_ID1 EMP_NAME2 EMP_ID2 DEPT_NAME1 DEPT_ID1 DEPT_NAME2 DEPT_ID2
1 SCOTT 10001 FRANK 10002 MARKETING 10 ACCOUNTING 20
2 SCOTT1 10003 FRANK1 10004 MARKETING1 30 My requirement is to:
SELECT from emp and INSERT INTO EMP_DEPT so that columns are broken into rows as follows
PK ENTY_TYPE, ENTY_NAME ENTY_ID
1 EMPLOYEE SCOTT 10001
2 EMPLOYEE FRANK 10002
3 DEPARTMENT MARKETING 10
4 DEPARTMENT ACCOUNTING 20
5 EMPLOYEE SCOTT1 10003
6 EMPLOYEE FRANK1 10004
7 DEPARTMENT MARKETING1 30 Thanks
Kevin
Edited by: user10210466 on Dec 8, 2010 1:37 PM -
Update sql help needed for hierarchy table
I am trying update the gross qty field based on each unit qty. This is how the table looks.
slevel | manager | seller |unit_qty | gross qty
0 | mary | mary | 1 | 1
.1 | mary | lynn| 3 | null
.1 | mary | betty | 2 | null
.1 | mary | alice | 2 | null
..2 | alice | susan | 1 | null
.1 | mary | amy | 4 | null
I would the table to look like this after the update, with the values
slevel | manager| seller | unit_qty | gross qty
0 | mary | mary | 1 | 1
.1 | mary | lynn| 3 | 3*1 ={color:#ff0000}3{color}
.1 | mary | betty | 2 | 2*1 ={color:#ff0000}2{color}
.1 | mary | alice | 2 | {color:#008000}2*1{color} ={color:#ff0000}2{color}
..2 | alice | susan | {color:#0000ff}1{color} | {color:#008000}2*1{color}{color:#0000ff}*1{color} ={color:#ff0000}2{color}
.1 | mary | amy | 4 | 4*1 = {color:#ff0000}4
{color}
This is the sql statement I tried to use without sucess.
update table set gross_qty = unit_qty * ({color:#ff0000}select gross_qty from table{color}
{color:#ff0000}where manager=seller{color})
where slevel >0Perhaps the old EXP (SUM (LN (n))) trick for calculating the product.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> CREATE TABLE seller (
2 manager VARCHAR2 (5),
3 seller VARCHAR2 (5),
4 unit_qty NUMBER,
5 gross_qty NUMBER);
Table created.
SQL> INSERT INTO seller (manager, seller, unit_qty) VALUES (NULL, 'mary', 1);
1 row created.
SQL> INSERT INTO seller (manager, seller, unit_qty) VALUES ('mary', 'lynn', 3);
1 row created.
SQL> INSERT INTO seller (manager, seller, unit_qty) VALUES ('mary', 'betty', 2);
1 row created.
SQL> INSERT INTO seller (manager, seller, unit_qty) VALUES ('mary', 'alice', 2);
1 row created.
SQL> INSERT INTO seller (manager, seller, unit_qty) VALUES ('alice', 'susan', 1);
1 row created.
SQL> INSERT INTO seller (manager, seller, unit_qty) VALUES ('mary', 'amy', 4);
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT manager, seller, unit_qty, gross_qty
2 FROM seller;
MANAG SELLE UNIT_QTY GROSS_QTY
mary 1
mary lynn 3
mary betty 2
mary alice 2
alice susan 1
mary amy 4
6 rows selected.
SQL> UPDATE seller s1
2 SET s1.gross_qty = (SELECT EXP (SUM (LN (s2.unit_qty)))
3 FROM seller s2
4 START WITH s2.seller = s1.seller
5 CONNECT BY s2.seller = PRIOR s2.manager);
6 rows updated.
SQL> SELECT manager, seller, unit_qty, gross_qty
2 FROM seller;
MANAG SELLE UNIT_QTY GROSS_QTY
mary 1 1
mary lynn 3 3
mary betty 2 2
mary alice 2 2
alice susan 1 2
mary amy 4 4
6 rows selected.
SQL> -
Help needed in returning multiple columns from one field
Hi,
I have been given a task to rewrite the query (see below), so that I get three columns from the one field, based on their contents.
The script returns all the columns and concatenates them into one, but returns them as comma delimmited within the returned column, to generate a report.
These tables are from Siebel.
Our Oracle version is:
select banner from sys.v_$version;
--returns
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for Solaris: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
Here is what I was given;
set arraysize 200
Spool d:\Daily_reports\Data\RegManage\Electricity\eCISPLUS_Product_Switch_Not_Started_Discount.csv
-- this will concatenate all the returned columns into one
SELECT DISTINCT '"'||
rtrim(ltrim(S_ORG_EXT.OU_NUM)) || '","' ||
rtrim(ltrim(S_ORG_EXT.NAME)) || '","' ||
rtrim(ltrim(S_EVT_ACT.TODO_CD)) || '","' ||
rtrim(ltrim(S_EVT_ACT.EVT_STAT_CD)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_SOURCE_TYPE)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_TXU_PRICELIST_NAME)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PEAKANYTIME_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PA_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_ORG_EXT.X_OTH_ACCOUNT_NUMBER)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_NUM)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_CHECKSUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.QUOTE_NUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_COOLING_OFF_DATE)) || '","' ||
rtrim(ltrim(S_PROD_INT.NAME)) || '"'
The field S_PROD_INT.NAME is the one that I need to split so that it is retured
into three different columns.
1st column needed -
where S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge __ %'
OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now __ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More __ %'
OR S_PROD_INT.NAME Like 'Electricity Mates Rates __ %'
2nd column needed -
where S_PROD_INT.NAME Like 'Gas TRUenergy Business Edge __ %'
OR S_PROD_INT.NAME Like 'Gas TRUenergy Business Now __ %'
OR S_PROD_INT.NAME Like 'Gas Go for More __ %'
OR S_PROD_INT.NAME Like 'Gas Mates Rates __ %'
3rd column needed from
S_PROD_INT.NAME Like '* ___ Discount for Paying Your Bill by the Due Date')
-- Tables
FROM SIEBEL.S_ADDR_PER S_ADDR_PER,
SIEBEL.S_DOC_QUOTE S_DOC_QUOTE,
SIEBEL.S_EVT_ACT S_EVT_ACT,
SIEBEL.S_ORG_EXT S_ORG_EXT,
SIEBEL.S_PRI_LST S_PRI_LST,
SIEBEL.S_PROD_INT S_PROD_INT,
SIEBEL.S_QUOTE_ITEM S_QUOTE_ITEM
WHERE S_EVT_ACT.TARGET_OU_ID = S_ORG_EXT.ROW_ID
AND S_DOC_QUOTE.ROW_ID = S_QUOTE_ITEM.SD_ID
AND S_ADDR_PER.ROW_ID = S_ORG_EXT.PR_ADDR_ID
AND S_PROD_INT.ROW_ID = S_QUOTE_ITEM.PROD_ID
AND S_ORG_EXT.ROW_ID = S_DOC_QUOTE.TARGET_OU_ID
AND S_DOC_QUOTE.PRI_LST_ID = S_PRI_LST.ROW_ID
AND S_EVT_ACT.TODO_CD = 'Product Switch-Electricity'
AND S_EVT_ACT.EVT_STAT_CD In ('In Progress','Not Started','On Hold')
AND S_DOC_QUOTE.STAT_CD In ('Completed','Verbal Acceptance','Written Acceptance')
AND S_DOC_QUOTE.X_OFFER_TYPE = 'Product Switch'
AND (S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge __ %' OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now __ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More __ %' OR S_PROD_INT.NAME Like 'Electricity Mates Rates __ %'
OR S_PROD_INT.NAME Like 'Electricity __ Discount for Paying Your Bill by the Due Date' or S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge ___ %'
OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now ___ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More ___ %'
OR S_PROD_INT.NAME Like 'Electricity Mates Rates ___ %'
OR S_PROD_INT.NAME Like 'Electricity ___ Discount for Paying Your Bill by the Due Date')
UNION
SELECT DISTINCT '"'||
rtrim(ltrim(S_ORG_EXT.OU_NUM)) || '","' ||
rtrim(ltrim(S_ORG_EXT.NAME)) || '","' ||
rtrim(ltrim(S_EVT_ACT.TODO_CD)) || '","' ||
rtrim(ltrim(S_EVT_ACT.EVT_STAT_CD)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_SOURCE_TYPE)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_TXU_PRICELIST_NAME)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PEAKANYTIME_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PA_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_ORG_EXT.X_OTH_ACCOUNT_NUMBER)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_NUM)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_CHECKSUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.QUOTE_NUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_COOLING_OFF_DATE)) || '"'
FROM SIEBEL.S_ADDR_PER S_ADDR_PER,
SIEBEL.S_DOC_QUOTE S_DOC_QUOTE,
SIEBEL.S_EVT_ACT S_EVT_ACT,
SIEBEL.S_ORG_EXT S_ORG_EXT,
SIEBEL.S_PRI_LST S_PRI_LST
WHERE S_EVT_ACT.TARGET_OU_ID = S_ORG_EXT.ROW_ID
AND S_ADDR_PER.ROW_ID = S_ORG_EXT.PR_ADDR_ID
AND S_ORG_EXT.ROW_ID = S_DOC_QUOTE.TARGET_OU_ID
AND S_DOC_QUOTE.PRI_LST_ID = S_PRI_LST.ROW_ID
AND S_EVT_ACT.TODO_CD = 'Product Switch-Electricity'
AND S_EVT_ACT.EVT_STAT_CD In ('In Progress','Not Started','On Hold')
AND S_DOC_QUOTE.STAT_CD In ('Completed','Verbal Acceptance','Written Acceptance')
AND S_DOC_QUOTE.X_OFFER_TYPE = 'Product Switch'
AND NOT EXISTS (SELECT /*+ unnest */ 'X'
FROM SIEBEL.S_PROD_INT S_PROD_INT, SIEBEL.S_QUOTE_ITEM S_QUOTE_ITEM
WHERE S_DOC_QUOTE.ROW_ID = S_QUOTE_ITEM.SD_ID
AND S_PROD_INT.ROW_ID = S_QUOTE_ITEM.PROD_ID
AND (S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge __ %'
OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now __ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More __ %'
OR S_PROD_INT.NAME Like 'Electricity Mates Rates __ %'
OR S_PROD_INT.NAME Like 'Electricity __ Discount for Paying Your Bill by the Due Date' or S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge ___ %'
OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now ___ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More ___ %'
OR S_PROD_INT.NAME Like 'Electricity Mates Rates ___ %'
OR S_PROD_INT.NAME Like 'Electricity ___ Discount for Paying Your Bill by the Due Date'));
spool off
This is what one row looks like;
"1-UWLHY","Alpha Vic Kelly Kay","Product Switch-Electricity","Not Started","AMBASS_50REBATE","Go Green PKANY-Powercor","QEGS1","GG","QEGS1","GG","","6407421678","8","1-UWLI6","12-JUN-07","Electricity Mates Rates 7% Discount"
we want
"1-UWLHY","Alpha Vic Kelly Kay","Product Switch-Electricity","Not Started","AMBASS_50REBATE","Go Green PKANY-Powercor","QEGS1","GG","QEGS1","GG","","6407421678","8","1-UWLI6","12-JUN-07",'Electricity Mates Rates 7% Discount","Gas TRUenergy Business Edge 10% Discount","Electricity 3% Discount for Paying Your Bill by the Due Date"
I have tried to:
- create a cursor
- each column as - ie
S_PROD_INT.NAME as "EVD",
S_PROD_INT.NAME as "GVD",
S_PROD_INT.NAME as "PbDDD"
but when I try to use them in where "EVD" Like 'etc...'
error that table does not exist
I have tried also as
where 'EVD' Like 'etc...' -- error
where EVD Like 'etc...' -- error
- create them as %TYPE variable
- more
but keep getting errors
Any ideas and help will be most appreciated as I have tried and researched all I can think and get my hands on with my limited skills.
Thanks.
Regards, SteveUnfortunately my skills are not high enough as I obviously don't know where to put the code exaclty.
I am first just running it on the top part of the script but get the error;
ORA-00900: invalid SQL statement
What I am running is; -- Commented
WITH s_prod_int AS
SELECT 1 row_id, 'Electricity Mates Rates 7% Discount' name FROM s_prod_int --these were 'FROM dual' originally, I changed to s_prod_int (Received same error regardless whether from dual or s_prod_int)
UNION ALL
SELECT 1, 'Gas TRUenergy Business Edge 10% Discount' FROM s_prod_int
UNION ALL
SELECT 1, 'Electricity 3% Discount for Paying Your Bill by the Due Date' FROM s_prod_int
SELECT DISTINCT '"'||
rtrim(ltrim(S_ORG_EXT.OU_NUM)) || '","' ||
rtrim(ltrim(S_ORG_EXT.NAME)) || '","' ||
rtrim(ltrim(S_EVT_ACT.TODO_CD)) || '","' ||
rtrim(ltrim(S_EVT_ACT.EVT_STAT_CD)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_SOURCE_TYPE)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_TXU_PRICELIST_NAME)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PEAKANYTIME_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PA_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_ORG_EXT.X_OTH_ACCOUNT_NUMBER)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_NUM)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_CHECKSUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.QUOTE_NUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_COOLING_OFF_DATE)) || '","' ||
rtrim(ltrim(a.name)) ||'","'|| --I assume I am still able to right and left trim
rtrim(ltrim(b.name)) ||'","'||
rtrim(ltrim(c.name))||'"' name -- not sure what this name is here for (have ran with and without it here
FROM SIEBEL.S_ADDR_PER S_ADDR_PER,
SIEBEL.S_DOC_QUOTE S_DOC_QUOTE,
SIEBEL.S_EVT_ACT S_EVT_ACT,
SIEBEL.S_ORG_EXT S_ORG_EXT,
SIEBEL.S_PRI_LST S_PRI_LST,
s_prod_int a, -- I assume these needed to go in here
s_prod_int b,
s_prod_int c
SIEBEL.S_QUOTE_ITEM S_QUOTE_ITEM
WHERE S_EVT_ACT.TARGET_OU_ID = S_ORG_EXT.ROW_ID
AND S_DOC_QUOTE.ROW_ID = S_QUOTE_ITEM.SD_ID
AND S_ADDR_PER.ROW_ID = S_ORG_EXT.PR_ADDR_ID
AND S_PROD_INT.ROW_ID = S_QUOTE_ITEM.PROD_ID
AND S_ORG_EXT.ROW_ID = S_DOC_QUOTE.TARGET_OU_ID
AND S_DOC_QUOTE.PRI_LST_ID = S_PRI_LST.ROW_ID
AND S_EVT_ACT.TODO_CD = 'Product Switch-Electricity'
AND S_EVT_ACT.EVT_STAT_CD In ('In Progress','Not Started','On Hold')
AND S_DOC_QUOTE.STAT_CD In ('Completed','Verbal Acceptance','Written Acceptance')
AND S_DOC_QUOTE.X_OFFER_TYPE = 'Product Switch'
AND a.NAME LIKE 'Electricity TRUenergy Business Edge%' --Placed all the where part in the original where clause
OR a.NAME LIKE 'Electricity TRUenergy Business Now%'
OR a.NAME LIKE 'Electricity Go for More%'
OR a.NAME LIKE 'Electricity Mates Rates%'
AND a.row_id = b.row_id
AND (
b.NAME LIKE 'Gas TRUenergy Business Edge%'
OR b.NAME LIKE 'Gas TRUenergy Business Now%'
OR b.NAME LIKE 'Gas Go for More%'
OR b.NAME LIKE 'Gas Mates Rates%'
AND b.row_id = c.row_id
AND (
c.NAME LIKE '%Discount for Paying Your Bill by the Due Date'
NAME -- Not sure what this NAME is for - tried with and without - same error -
SQL help, how to group by column A and then get top frequency of column B?
Assuming the following table, operation represents each kind of transaction operation
table operation employee other column c
'<' id1
'<' id1
'<' id2
'*' id3
'/' id1
question, for each operation, which employee do the most? which employee do the 2nd most?
I thought I need to group by operation first, and then get the frequency of employee, and get the top 1 or top 2 frequency highest.
But I am stuct, and do not know how to write the sql.998408 wrote:
Assuming the following table, operation represents each kind of transaction operation
table operation employee other column c
'<' id1
'<' id1
'<' id2
'*' id3
'/' id1
question, for each operation, which employee do the most? which employee do the 2nd most?
I thought I need to group by operation first, and then get the frequency of employee, and get the top 1 or top 2 frequency highest.
But I am stuct, and do not know how to write the sql.Welcome to OTN. Ops! posted in wrong forum. Just post in {forum:id=75}. Before posting there close this thread marking as answered.
If someone's response is helpful or correct, please mark it accordingly.* -
Help needed regarding the updation of "Relationships" in BP
Hello Guys,
This is to request you to kindly help me regarding the following.
We have a scenario where all the employees assigned to an Organizational unit (in PPOMA_CRM) are not showing in the "Relationships" ("Has Employee")in the BP transaction of that Organizational Unit.
Could anyone let me know whether there is any update program that updates the "Relationships" from the Organizational asssignment. Or we need to enter the employees manually in BP "Relationships". Please help. Thanks in anticipation.
Regards,
Kishore.Hi Amit,
Thanks alot for your reply. Its really helpful for me.
So,we usually enter these relationships manually only, right? Before going ahead with the custom program, could you please let me know whether there is any SAP note related to this.Once again thanks alot for you help.
Regards,
Kishore. -
SQL HELP NEEDED IN QUERY FOR COUNT
I Have this Query
SUM (CASE WHEN b.VET_OTHR_ELIG_CDE IN ('02', '03', '04') THEN 1 END) AS VET_YES,
SUM (CASE WHEN b.VET_OTHR_ELIG_CDE = '01' THEN 1 END) VET_NO, COUNT (E.ACTV_CDE) AS CNT_ACTV_CDE
Now i need to Add two more columns from the same Query Showing the count of VET_YES and VET_NO i.e count of TOTAL Veterans And TOTAL Non Veterans
those two columns i will be using as summary columns in my report.The bolded columns are those which i need to show the total column .anyone please help in this issue ..
ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_ACTV_CDE
INACT DUE 13993 2 1 3
NOW I NEED TO MAKE IT LIKE THIS
ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_VET CNT_NONVET CNT_ACTV_CDE (This is the total count)
INACT DUE 13993 2 1 2 1 3
Thanks in Advance,
Dev Kishore.T
Message was edited by:
Dev Kishore
Message was edited by:
Dev KishoreCheck this link.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
Regards
Raj -
Help needed for dynamic update form
I could really use some advice - I've been asked to build a time tracking application (basically a timesheet) and I have a fair bit done but the part I am really struggling with is the best way to accommodate some of the specifications. I am NOT a programmer (I have some coldfusion experience but nothing really advanced) so I have not managed to sucessfully integrate the various methods I've found on the web so far. The database is created and so are all the queries, and I have also written a cfc to handle the drop-down menu logic needed but I don't really know how to integrate it with the form.
Our production server has ColdFusion MX7 so all the great functionality in the CF8 examples I can't use.
The issue is the user should ideally be able to add/edit/delete multiple rows at once- I like CFGRID, and the HTML version seems best. The main issue with the Flash version is the scrolling to get to the insert/delete buttons- I couldn't see how to get rid of that. A separate add and edit form could be ok depending on how easy it is to use.
One problem I have is that I can't work out how to have default values with the grid (the userID which is a session variable, and the date which is constantly changing- there is a cfcalendar for the user to change date).
The biggest hurdle is the related select drop-downs I need- it's not quite as simple as the city,state,postcode examples. For the first drop down the pick an option- and for only 2 of those options there is a second drop-down. Anything else and it stops there. For the second drop-down, there are 2 options, and depending on which one of these they pick the 3rd drop-down pulls a query from one or another table in the database (2 entirely different things). The three options have different database tables. The main timesheet table just stores the id number from those tables (so I also need to display the names on the drop-down from the options tables not the number).
I played with simple and complicated javascript and coldfusion solutions as well, but because it's a form to update records and also because of the above specs I just couldn't get anything to work right. I tried binding with the cfc and nothing would bind, plus I don't know how to make all happen without a page reload.
Does anyone have any advice for the best approach to this? As I mentioned I've got tables, queries and even a cfc but I'm not too clear on how to put it all together properly within the constraints of MX7.
PS I also can't post a lot of code because of where I work- I know that's not helpful but am looking for the best approach to this, then I can work on the details. Right now I am jumping from solution to solution and not getting anywhere.Well, a lot of code has come and gone because I couldn't make it work, where I'm currently at is:
<cfform name="updateform" id="updateform" action="#CurrentPage#?#CGI.QUERY_STRING#">
<cfgrid name="MainData" height="400" insertbutton="add" deletebutton="remove" query="getMainData" insert="yes" delete="yes" rowheight="20" selectmode="edit" format="html">
<cfgridcolumn name="id" display="no">
<cfgridcolumn name="userID" display="no">
<cfgridcolumn name="entrydate" display="no">
<cfgridcolumn name="activityID" >
<cfgridcolumn name="typeID">
<cfgridcolumn name="projectID" values="#ValueList(getProjects.id)#" valuesdisplay="#ValueList(getProjects.name)#">
<cfgridcolumn name="time" width="10">
<cfgridcolumn name="comment" width="150">
</cfgrid>
<cfinput type="hidden" name="entrydate" value="#Session.username#">
<cfinput type="hidden" name="entrydate" value="#editdate#">
<cfinput name="update" type="Submit" value="Update">
</cfform>
** for some reason getProjects.name doesn't work and causes an error. I haven't worked out how to get the default inputs for the date and user ID to work either. I also tried binding and a flash form somewhere along the way.
** the CFC is below, #ds# didn't work and I had to put in the actual DSN name, not sure why, but anyway this is the logic of the thing. Ideally I would like to use this logic with the cfgrid, but I'm not sure if that is possible? It seems like it would be the most user friendly approach.
The CFC so far is:
<cfcomponent>
<cffunction name="getActivities" access="remote" returnType="query">
<cfquery name="getActivities" datasource="#ds#">
SELECT * FROM timesheet_activities
</cfquery>
<cfreturn getActivities>
</cffunction>
<cffunction name="getTypes" access="remote" returnType="query">
<cfargument name="Activity" type="any" required="true">
<cfif ARGUMENTS.Activity EQ "">
<cfset getType = "">
<cfelse>
<cfquery name="getTypes" datasource="#ds#">
SELECT * FROM timesheet_type
</cfquery>
</cfif>
<cfreturn getTypes>
</cffunction>
<cffunction name="GetProjects" access="remote" returnType="query">
<cfargument name="Activity" type="any" required="true">
<cfargument name="Type" type="any" required="true">
<cfif ARGUMENTS.Activity EQ "" OR ARGUMENTS.Type EQ "">
<cfset LstProjects = "">
<cfelseif ARGUMENTS.Activity EQ "1" OR "3">
<cfquery name="getProjects" datasource="#ds#">
SELECT id,name FROM projectsa
WHERE completed = 'false'
</cfquery>
<cfelse>
<cfquery name="getEProjects" datasource="#dse#">
SELECT id,name FROM projectsb
WHERE statusID = '6'
</cfquery>
</cfif>
<cfreturn getProjects>
</cffunction>
</cfcomponent>
Any attempts to actually use the cfc didn't work. I tried to use it with a normal html update form and got the message- failed to bind, Activity didn't exist. I also tried to bind it to a flash grid. The argument for Activity needs to come from the drop-down Activity type selected. Maybe I'm missing something.
ETA:
just moved everything to the live MX7 server (because my dev server is Coldfusion8) and I get the following:
Attribute validation error for tag CFGRID. The tag does not allow the attribute(s) BINDONLOAD,BIND.
Does this mean I definitely can't use the CFC with the cfgrid on MX7? Or is there a way to do it?
Any advice would be greatly appreciated. -
sql gurus
Oracle 11.2.0.2
OS : AIX
Requirement: I have a sql which generates rows between 100 and 150 daily. Changes depending on the dml.
I need to generate 3 reports
Report 1
ex :
if total rows =120
1st report contain starting from row 1 upto row (total div 3)
Row 1 to Row 40
Report 2
Row (total div 3) +1 to (total div 3) *2
Report
Row ((total div 3) *2) + 1 to Total rows.
Currently the process of identifying this manual
apart from using plsql
Is it possible to do thru sql to get this done
pl. let me know.
I hope I have explained the problem clearlyHi,
gl**** wrote:
... I hope I have explained the problem clearlyNo matter how clearly you explain a problem, you still ought to post CREATE TABLE and INSERT statements for some sample data, and the results you want from that data, as Hoek said. Explain how you get the results you want from that data. For example, you talk about getting rows 1 through (N/3), but you haven't said what determines the order of the rows. (In the query below, I assume it's a column called column_1.)
Simplify the problem when you can. For example, instead of having 100 to 150 rows, post a problem that involves 6 to 8 rows.
One way to do this in pure SQL is to use the NTILE function to divide the results evenly (as evenly as possible) into 3 groups, and only display one of the groups at a time, like this:
WITH got_third AS
SELECT x.*
, NTILE (3) OVER (ORDER BY column_1) AS third
FROM table_x x
WHERE ... -- If you need any filtering, put it here
SELECT * -- Or list all columns except third
FROM got_third
WHERE third = :third_wanted
;It would be more efficient if you generated all of the results at once, and then divided the output file into 3 parts, but an inefficient solution might be acceptable in this case. -
Grouping Rules in PL/SQL Help needed
Hi I have a requirement where I wan to group based on the below scenario
I have a Table_A
Table_A strcuture:
create table table_a
code number,
name varchar2 (100),
city varchar2 (100),
dept varchar2 (100));;
insert into table_a
values
1,'ABC','EA','A');
insert into table_a
values
1,'ABC','EA1','A');
insert into table_a
values
2,'BCD','EA2','A');
insert into table_a
values
2,'ABC','EA3','A'');
insert into table_a
values
3,'KBC','EA,'A');
insert into table_a
values
3,'ABC','EA,'A');
wan to group the above table data based on name,city,dept
I wan the data as
1 ABC EA1 A
BCD EA2 A
2 BCD EA2 A
ABC EA3 A
3 KBC EA A
BCD EA A
Kindly any help will be needful for meThis is more of a presentation layer problem I would not handle it in SQL. For example if the presentation layer is SQL Plus you can use BREAK command, like this.
SQL> select * from table_a;
CODE NAME CITY DEPT
1 ABC EA A
1 ABC EA1 A
2 BCD EA2 A
2 ABC EA3 A
3 KBC EA A
3 ABC EA A
6 rows selected.
SQL> break on code
SQL>
SQL> select * from table_a order by code;
CODE NAME CITY DEPT
1 ABC EA A
ABC EA1 A
2 BCD EA2 A
ABC EA3 A
3 KBC EA A
ABC EA A
6 rows selected.
But if you still wish to do it in SQL the right way is to use ROW_NUMBER like this.
SQL> clear breaks
breaks cleared
SQL>
SQL> select * from table_a;
CODE NAME CITY DEPT
1 ABC EA A
1 ABC EA1 A
2 BCD EA2 A
2 ABC EA3 A
3 KBC EA A
3 ABC EA A
6 rows selected.
SQL> select decode(rno, 1, code) code
2 , name
3 , city
4 , dept
5 from (
6 select row_number() over(partition by code order by name) rno
7 , t.*
8 from table_a t
9 )
10 /
CODE NAME CITY DEPT
1 ABC EA A
ABC EA1 A
2 ABC EA3 A
BCD EA2 A
3 ABC EA A
KBC EA A
6 rows selected. -
Help needed with an update query
Hi,
I am trying to execute an update query on a table. Here is an example: I have 2 tables t1 and t2 and these tables have 2 similar columns, c11 and c12 in t1 and c21 and c22 in t2. I have to now execute an update statement for the column c11 in t1 with the values for c21 in t2 where the c12 in t1 is equal to c22 in t2. So, the query which I have formulated is:
update t1 set c11 =
(select t2.c21 from t1,t2 where t1.c11=t2.c22)
where t1.c11 in (select t1.c11 from t1);
But this query gives me an error: ORA-01427: single-row subquery returns more than one row.
Where am i going wrong? Kindly help.Hi,
CrazyAnie wrote:
Hi,
I am trying to execute an update query on a table. Here is an example: I have 2 tables t1 and t2 and these tables have 2 similar columns, c11 and c12 in t1 and c21 and c22 in t2. I have to now execute an update statement for the column c11 in t1 with the values for c21 in t2 where the c12 in t1 is equal to c22 in t2. So, the query which I have formulated is:
update t1 set c11 =
(select t2.c21 from t1,t2 where t1.c11=t2.c22)
where t1.c11 in (select t1.c11 from t1);
But this query gives me an error: ORA-01427: single-row subquery returns more than one row.
Where am i going wrong? Kindly help.Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements for all tables) and the results you want from that data.
In this case, where the problem involves changing t1, the INSERT statements should show reflect the state of the tables before the UPDATE, and the results are shat's in t1 after the UPDATE.
Without that information, people can only guess at the solution.
As the error message said, the problem is that the sub-query:
(select t2.c21 from t1,t2 where t1.c11=t2.c22) is returning more than one row. Each row of t1 can only have one value for c11; which one is it supposed to be?
It's unusual to have an UDPATE on a table be based on a join of that same table and another table. It's not necessarily wrong, but a more common UPDATE statement is:
update t1
set c11 = ( select t2.c21
from t2
where t1.c12 = t2.c22
where t1.c12 in ( select c22
from t1
);But again, I don't know where you're starting from (sample data), or where you want to go (results from that data), so it's hard to give you good directions. -
Major help needed with replacing xskey
here's the pickle...
i lost my logic pro 7 xskey while traveling.
i can't install/update studio without it, nor run pro 7.
i am currently in a country that doesn't have apple support phone lines.
i can't contact any other apple support phone lines from where i currently am.
I NEED TO FIND A SOLUTION ONLINE, FAST !!!
someone that has information/influence please help me.
praying for a solution.You didn't say why you are installing. If you've already installed the upgrade on your machine, you won't need the key.
If you are reinstalling, you shouldn't need to key (because your machine is already authorised).
If you are trying to install your copy of LS on a different machine entirely, then that's different. If you are re-installing on your main machine because you had to reformat, if you'd save your authorisation file you may not have needed to reauthorise again.
What I'm saying is, if you gave some specifics of what and why you are doing this, then I might have been able to help you without having to bother Apple.
But if you are trying to install on a different machine and don't have your dongle, the only people who can legally help you is Apple. Can you phone a friend in the respective country and get them to phone Apple on your behalf? -
I tried to update Photoshop CC 2014, but it failed at 75%, with error code U44M1I210. After restarting my system, it still failed so I uninstalled the app, per this article: https://helpx.adobe.com/creative-suite/kb/error-u44m1i210-installing-updates-ccm.html
Now the reinstall won't complete, and I'm getting error -55. The one other article that seemed relevant looks like the person had to uninstall and reinstall all his Adobe software after creating a new admin account on his computer (When I try to update I get an U44M1I210 error message, "Unable to extract the downloaded files" - help please, applies to latest Indesign, Illustrator and Photoshop CC), and I'm hoping there is a better solution than the hours that will involve.
Running on OSX 10.7.5.
Any help greatly appreciated.
Thanks!GundamCat what specific errors were you able to discover in the installation log for the update?
-
Help needed - How to update Garageband 3
Hi!
I got my friend's old Macbook (Mac Os X 10.6.8) and am not familiar with the whole Mac world yet, so my question might be a little naive
Garageband 3 is installed but not working properly as all the loops are missing.
How can I update version 3? I downloaded version 10.0.1 but cannot be installed as it's not fitting.
Before you ask: I tried the update link in the program itself, but it's dead. I guess it's just too old now. I also tried to download the newest version, but it's only compatible with Mac Os X 10.9 and further).
Help!!! :/
Thank you very much in advance!
B*The original loops are not sold separately, only additional JamPacks, if you can find them, and they are are much more expensive than buying iLife. And I do not remember, if the JamPacks are compatible with GarageBand 3. Did your friend transfer the installation CDs to you, when you got the Mac? If MacOS X 10.6.8 was the original system of the Mac, the installer CDs may contain bundled iLIfe applications.
Maybe you are looking for
-
The iPod 'iPod' could not be restored.An unknown error occured(9).
I got my iPTouch 16 GB on Oct.13 and on hooking to XP SP2 PC got it on the iTunes ver 7.4.3.1, was able to download music after charging. iTunes showed that a new software ver 1.1.1 for iPTouch was available(of150MB).Got it downloaded to iTunes but w
-
Every night at the office, I run a script that rsyncs files from our production server to my local machine, as a backup just in case, and also until we get a git solution setup. I would then use Time Machine, setup on a partition on the main drive, t
-
Help required in developing SQL developer extension
Hi, We have a requirement to develop an extension for Sql Developer. The requirement matches the Reports framework in Sql Developer. We need to have a separate dock as in reports where we can navigate through the tree and execute some predefined quer
-
Can't get ny recovery disk to download drivers
my.H.P.pavilion zd7000 went bonkers.so got a new hardrive got recovery disks from H.P. have the windows X.P. on and good.no internet the recovery disk foe the drivers won't download
-
Cooling Options? Mac Pro Heating Up Room
Hi there. The AC in the house cannot keep my office cool (12ft by 15ft), it always hovers around 82 degrees while the rest of the house is 72. If the computer is off the room is fine. I'm looking for options to cool my Mac Pro and RAID array. 1) I've