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 me
This 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.
Similar Messages
-
GROUP BY and ORDER BY help needed
I have got an sql query where I have the need to pull out the latest copy of duplicate info, but what is happening is that the first instance is being displayed. The query I have is this:
SELECT *
FROM tbl_maincontenttext
WHERE fld_menusection = 3
GROUP BY fld_webpage
ORDER BY fld_timedate DESC
Basically, I have content that is listed under menu section 3, but within that I will have several copies of content that will relate to a specific webpage (eg: about us). What is currently happening is that GROUP BY is obviously grouping the similarly named 'about us', but it is pulling the first record it comes across out of the database rather than the latest updated record.
As you can see, I am trying to get the query to order by fld_timedate which is a CURRENT_TIMESTAMP, but it's not working!
I'm hoping that there is some sort of SQL that I am unaware of that will help me group by and display the latest update/content.
Thanks.
MatIt would help if you could show us the table definition. Your SQL statement is ambigous because you are selecting all table columns, yet only including one column in the group by clause. A SQL statement must contain all selected columns that are not aggregates. Most DBMS will return an error for this statement. Others that don't return an error will return unexpected results.
-
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. -
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 -
SQL Help Need to Calculate Count beteen two dates.
CREATE TABLE SUPPORT_SERVICES.LOAN_ACTION
LOAN_NBR NUMBER(10),
ACTION_CODE VARCHAR2(20 BYTE),
DOC_CODE VARCHAR2(20 BYTE),
ACTION_DATE DATE
SET DEFINE OFF;
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'ASSIGN', 'MORT', TO_DATE('12/01/2011 20:24:38', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'PASSIGN', 'MORT', TO_DATE('12/02/2011 20:24:38', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'QASSIGN', 'MORT', TO_DATE('12/03/2011 20:24:38', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'RASSIGN', 'MORT', TO_DATE('12/09/2011 20:24:38', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'SASSIGN', 'MORT', TO_DATE('12/04/2011 20:24:38', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'TASSIGN', 'MORT', TO_DATE('12/05/2011 20:24:38', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'UASSIGN', 'MORT', TO_DATE('12/06/2011 20:24:38', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'YASSIGN', 'MORT', TO_DATE('12/07/2011 20:24:38', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(100, 'xASSIGN', 'MORT', TO_DATE('12/08/2011 20:24:39', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(101, 'ASSIGN', 'MORT', TO_DATE('12/01/2011 20:24:39', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(101, 'PASSIGN', 'MORT', TO_DATE('12/02/2011 20:24:39', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(101, 'QASSIGN', 'MORT', TO_DATE('12/03/2011 20:24:39', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(101, 'SASSIGN', 'MORT', TO_DATE('12/04/2011 20:24:39', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(101, 'TASSIGN', 'MORT', TO_DATE('12/05/2011 20:24:39', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(101, 'UASSIGN', 'MORT', TO_DATE('12/06/2011 20:24:39', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(101, 'YASSIGN', 'MORT', TO_DATE('12/07/2011 20:24:39', 'MM/DD/YYYY HH24:MI:SS'));
Insert into LOAN_ACTION
(LOAN_NBR, ACTION_CODE, DOC_CODE, ACTION_DATE)
Values
(101, 'UNASSIGN', 'MORT', TO_DATE('12/08/2011 20:24:40', 'MM/DD/YYYY HH24:MI:SS'));
COMMIT;Could some one please give me a idea to solve following scenario .
from the above table i want to count DOC_CODE column values between action_code ='ASSIGN' AND action_code 'UNASSIGN'
example :
LOAN_NBR ACTION_CODE DOC_CODE ACTION_DATE
101 ASSIGN MORT 12/1/2011 8:24:39 PM
101 PASSIGN MORT 12/2/2011 8:24:39 PM
101 QASSIGN MORT 12/3/2011 8:24:39 PM
101 SASSIGN MORT 12/4/2011 8:24:39 PM
101 TASSIGN MORT 12/5/2011 8:24:39 PM
101 UASSIGN MORT 12/6/2011 8:24:39 PM
101 YASSIGN MORT 12/7/2011 8:24:39 PM
101 UNASSIGN MORT 12/8/2011 8:24:40 PMFor Loan Number 101 ,ACTION_CODE='ASSIGN' was on 12/1/2011 and ACTION_CODE='UNASSIGN' was on 12/6/2011
so now the doc_count is 4 ;
Let me know if you need any additioanl infoamtion on this.
Thank you
VijayHi, Vijay,
Thanks for posting the CREATE TABLE and INSERT statements.
Don't forget to post the full results you want from that sample data, nor to say which version of Oracle you're using. (It probably doesn't matter this time; the query below works in Oracle 8.1 and higher.)
vijayp wrote:
from the above table i want to count DOC_CODE column values between action_code ='ASSIGN' AND action_code 'UNASSIGN'
example :
LOAN_NBR ACTION_CODE DOC_CODE ACTION_DATE
101 ASSIGN MORT 12/1/2011 8:24:39 PM
101 PASSIGN MORT 12/2/2011 8:24:39 PM
101 QASSIGN MORT 12/3/2011 8:24:39 PM
101 SASSIGN MORT 12/4/2011 8:24:39 PM
101 TASSIGN MORT 12/5/2011 8:24:39 PM
101 UASSIGN MORT 12/6/2011 8:24:39 PM
101 YASSIGN MORT 12/7/2011 8:24:39 PM
101 UNASSIGN MORT 12/8/2011 8:24:40 PMFor Loan Number 101 ,ACTION_CODE='ASSIGN' was on 12/1/2011 and ACTION_CODE='UNASSIGN' was on 12/6/2011
so now the doc_count is 4 ;U<b>N</b>ASSIGN was on 12/8.
UASSIGN (with no N before the end) was on 12/6.
>
Let me know if you need any additioanl infoamtion on this.What if either ASSIGN or UASSIGN occurs more than once for the same loan_nbr? The query below uses the earliest ASSIGN date and the latest UASSIGN date.
Thank you
Vijay
WITH got_date_range AS
SELECT loan_nbr, doc_code, action_date
, MIN ( CASE
WHEN action_code = 'ASSIGN'
THEN action_date
END
) OVER (PARTITION BY loan_nbr) AS assign_date
, MAX ( CASE
WHEN action_code = 'UASSIGN'
THEN action_date
END
) OVER (PARTITION BY loan_nbr) AS uassign_date
FROM loan_action
SELECT loan_nbr
, COUNT (doc_code) AS cnt_doc_code
FROM got_date_range
WHERE action_date > assign_date
AND action_date < uassign_date
GROUP BY loan_nbr
; -
Hello Everyone
I am using database 11g. Can someone pl suggest what are the rules for putting single quotes for dynamic sql like
1) how many single quotes before/after a sql statement .
2) Rules for putting single quotes if there exists i) a variable in the sql statement
ii) a constant for e.g 100 in the sql statment.
If you could give the answers with a simple select statement, it will be even better !!!
Thanks and regards
Gautamms wrote:
Hello Everyone
I am using database 11g. Can someone pl suggest what are the rules for putting single quotes for dynamic sql like
1) how many single quotes before/after a sql statement .
2) Rules for putting single quotes if there exists i) a variable in the sql statement
ii) a constant for e.g 100 in the sql statment.
If you could give the answers with a simple select statement, it will be even better !!!
Thanks and regards
Gautamwrite the SQL statement as you would for any SQL client & enclose it using Q-quote
http://askanantha.blogspot.com/2007/12/q-quote-operator-introduced-in-oracle.html
Handle: ms
Status Level: Newbie
Registered: Jun 3, 2007
Total Posts: 46
Total Questions: 17 (17 unresolved)
WOW!
*NEVER got any answer in 5+ years & still wasting time here again, still!
You must be an eternal optimist.
I hope I get credited for your FIRST answer. -
I am having trouble using OracleXML getXML, after
setting all the path variables in env.csh I try
java OracleXML getXML -user "user/passwd" "select a, b from blog"
but get the following error.
ORA-01019: unable to allocate memory in the user side
The same error occurs for jdk1.1.7 and jdk1.2
nullHi Dean,
It might be something to do with connecting through oci8 to the
Oracle executable. ( I am not sure since I dont know ur
configuration etc..). BTW what release of Oracle is this?
One thing for you to try out would be to write a small java
program against the OracleXMLQuery class to see if that works.
I have attached a very simple program below:-
import java.sql.*;
import java.math.*;
import oracle.xml.sql.query.*;
import oracle.jdbc.*;
import oracle.jdbc.driver.*;
public class testXML{
public static void main(String args[]) throws SQLException
DriverManager.registerDriver
(new oracle.jdbc.driver.OracleDriver());
Connection conn = (Connection)
DriverManager.getConnection("jdbc:oracle:oci8:scott/tiger@");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from emp");
OracleXMLQuery qry = new OracleXMLQuery(conn,rset);
String xmlString = qry.getXMLString();
System.out.println(" OUPUT IS "+xmlString);
This code does a select from emp table available in scott/tiger
schema. U can change the login and the table names
appropriately. SEtup all the environment variables etc.. (see
release notes), save this as testXML.java, run javac to get the
class and execute it using "java testXML". If this doesnt work,
try changing the getConnection line to use the thin jdbc, such
as,
DriverManager.getConnection
("jdbc:oracle:thin:@","scott","tiger");
You can check out the JDBC documentation for how to specify
your connection for your particular setup (such as specifying
the port number etc.. if needed).
Lemme know if it works,
Murali
Dean Kuo (guest) wrote:
: I am having trouble using OracleXML getXML, after
: setting all the path variables in env.csh I try
: java OracleXML getXML -user "user/passwd" "select a, b from
blog"
: but get the following error.
: ORA-01019: unable to allocate memory in the user side
: The same error occurs for jdk1.1.7 and jdk1.2
null -
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> -
Hi - using asp/vbscript/access
I struggle with a small SQL issue and hope that someone can
assist me;
I have one db table, lets call it "test".
Coloumns are ID, SubID, Name
ID holds the uniqe ID and headline for each record ( Name).
SubID holds the content linked to the corresponding ID.
Something like this;
ID1 - Shoe sizes
ID2 / SubID 1 - 40
ID3/ SubID 1 - 41
ID4/SubID 1 - 42
ID5 - Shoe Colors
ID6/SubID 5 - Red .......and so on.
I now try to display all the ID and SubID records in the same
order as the input;
SELECT *
FROM test
WHERE ID = SubID
This gives no result. Any idea how to display this?
Kind regards,
Bjørn.I'm trying to figure out how you made that table. If ID is an
autonumber,
how is the data under one record something like a title and
under another
one, a number? That isn't possible.
What exactly are you trying to accomplish?
Nancy Gill
Adobe Community Expert
BLOG:
http://www.dmxwishes.com/blog.asp
Author: Dreamweaver 8 e-book for the DMX Zone
Co-Author: Dreamweaver MX: Instant Troubleshooter (August,
2003)
Technical Editor: DMX 2004: The Complete Reference, DMX 2004:
A Beginner's
Guide, Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP
Web Development
"btn" <[email protected]> wrote in message
news:e9t94r$lcn$[email protected]..
> Hi - using asp/vbscript/access
>
> I struggle with a small SQL issue and hope that someone
can assist me;
>
> I have one db table, lets call it "test".
> Coloumns are ID, SubID, Name
> ID holds the uniqe ID and headline for each record (
Name).
> SubID holds the content linked to the corresponding ID.
>
> Something like this;
>
> ID1 - Shoe sizes
> ID2 / SubID 1 - 40
> ID3/ SubID 1 - 41
> ID4/SubID 1 - 42
> ID5 - Shoe Colors
> ID6/SubID 5 - Red .......and so on.
>
> I now try to display all the ID and SubID records in the
same order as the
> input;
>
> SELECT *
> FROM test
> WHERE ID = SubID
>
> This gives no result. Any idea how to display this?
>
> Kind regards,
>
> Bj?rn.
> -
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 -
For some reason System Preferences "Unexpectedly Quits" every time I try to go to the users preferences.
Here is a link to a video to it: http://youtu.be/bw2erpe0B8s
Also here is a link to the debug info: http://www.mediafire.com/view/?peju2065ktrphqn
THANKS!For some reason System Preferences "Unexpectedly Quits" every time I try to go to the users preferences.
Here is a link to a video to it: http://youtu.be/bw2erpe0B8s
Also here is a link to the debug info: http://www.mediafire.com/view/?peju2065ktrphqn
THANKS! -
R11i - AR Autoinvoice - Mandatory grouping rules (N deliveries = 1 invoice)
Hi.
We have one big client who has a lot of shipment addresses (for deliveries) and when all orders are invoiced we want to get only one invoice for all different deliveries (we cant just merge all orders in to one ship_to_address site).
The usual way for changing the way of grouping with autoinvoice is using different grouping rules (but only adding not removing):
Can the Mandatory grouping rules attributes be changed? (we would like to remove the ship_to_address attribute). Any other way to create only one invoice?
Oracle® Receivables - User Guide:
Grouping rules include mandatory attributes which are always included in all grouping
rules, and optional attributes which may be included in a grouping rule. Optional
attributes may be added to the mandatory attributes to create new grouping rules
Thanks for any help.
Kind regards,
Kristjan
Edited by: user10676522 on 28.4.2010 23:44Hi Kristjan,
No, you cannot change the mandatory grouping rules. As you know the ship_to_customer is one of the mandatory grouping columns, so if you want shipments to multiple ship_to locations to be all in one invoice, there is no other way but to remove the ship_to references from the ra_interface_lines_all table before you run autoinvoice. This obviously means that you lose the ship_to references on your invoice. To take care of that, you can pass on the ship_to information on the transaction line flexfield.
Hope this hepls.
Thanks,
Anil -
Help needed in PL/SQL for updating the column for multiple records
Hi,
I am new to PL/SQL and need some help. What is the most effiecient way to update some field in a table as I may need to update thousands of records. I have a coulmn groupid can have multiple records tied to it. All the records attached to some groupid have a priority field also.
How can I update the prorityfield value for all the groupids in a profiecient way. Here is a sample data
GroupId Priority
1 1
1 2
1 3
1 4
1 5
2 1
2 2
2 3
3 1Here I have three groups 1, 2, 3. Now if any group contains only one record the priority remains same e.g. groupid=3 on top. If any group contains more than one record e.g. groupid=1 & 2 I want to re-arrange the priority fields e.g. If I want to update groupid=1 now if I change the priority of 2 to 5 (make it the last) I want to rearrange the remaing records priority i.e. if 2 becomes 5 as I have 5 rows for groupid=1 then 5 becomes 4, 4 becomes 3, 3 becomes 2 and 1 remains the same.
Same wya if I want to make the priority 1 to 3 for groupid=2 then need 2 to become 1 and 3 to become 2 etc....
Any help is appreciated.
ThanksHi,
You don't need PL/SQL to do this (though you can put the following in PL/SQL if you want to):
UPDATE table_x
SET priority = CASE
WHEN groupid = 1
AND priority = 2
THEN 5
WHEN groupod = 1
AND priority BETWEEN 3 AND 5
THEN priority - 1
WHEN groupid = 2
THEN
CASE
WHEN prioity = 1
THEN 3
ELSE priority - 1
END
END
WHERE groupId IN (1, 2)
AND ( priority BETWEEN 2 AND 5
OR groupid = 2
);There are lots of different techniques that can reduce your coidng: for example, the nested CASE statement used for groupid=2 above.
You could do several smaller UPDATEs (for example, one just for groupid=1). Execution will be slower, but coding and testing will be faster.
You could make the "magic numbers" 2 (for groupid=1) and 1 (for groupid=2) variables, even outside of PL/SQL.
If you need more help, post the information that Satyaki requested. -
Help needed on update rules Coding
Hi BW Gurus.
Please help me out.
I am working on BI 7.0
This is my scenario.I need to take a project cost report.
There are some projects in cProjects and some projects in R/3 (Project System).
Each project in cProjects is linked with one or more projects in R/3.
They are linked by means of GUID.Now I need to pull out a report from a infocube(Z infocube) which has information both from R/3 and cProjects.I built a Z infocube.
Here comes my problem.
I need to write update rule for the requirement explained below.
For all the projects(in cProjects) I need to find its GUID from the table-DPR_PROJECT . These GUIDs are contained in this table under the field name GUID.
The same GUID numbers I can find it in another table-DPR_OBJLINK under the field PROJECT_GUID. For this PROJECT_GUID numbers, I need to identify the corresponding EXTERNAL_ID(this field is in the table-DPR_OBJLINK) of the projects(These projects are R/3 projects). These EXTERNAL_ID values has to be pulled out in the report.
I am using the extractor 0CO_OM_WBS_1.
Please help me out with the update rule code.
Please help me out as soon as possible.
Its really urgent my dear friends
Thanks in Advance,
Have a nice day
Regards,
Sam MathewHi Raogovind,
For which state are you customising this Professional Tax? Professional Tax wage type is /422.
The system determines the professional tax payable by an employee, based on the following factors:
Professional tax basis u2013 Comprises those salary components on which a professional tax is applicable. The salary components to be included for calculating the professional tax basis depend on the state. The different components are:
Basic pay
Dearness allowance
Medical reimbursement perquisite
Housing
Profits in lieu of salary
Other remuneration that an employee receives regularly
Bonus
It is depending on the combination of the Personnel Area, Personnel sub area and the professional tax grouping of the employee, that the system identifies factors such as the:
Components of the professional tax basis.
Method and the frequency of calculating and deducting professional tax.
Hope this information helps you solve the issue.
Edited by: chandra.saphr on Aug 6, 2009 7:10 AM
Maybe you are looking for
-
How do i set up a PHP,MYSQL,Apachie server on my macbook
I play a well known MMORPG (WoW) and my guild recently lost there site due to owner of the site leaving the guild, i had previously mentioned i had a little experience in designing but not developing so they asked me to develop a web site for the gui
-
How do i Change only the Installation No from Visual Admin
Hello All, As my license key for the NWDS expiry's after every 15Days. I have got a new license key but i need to change the Installation No of my older license in order to update it with the new one. or keep it running always with out any expiry.co
-
One of my users has requested a browse sequence, but I can't find the Browse Sequence Editor. Another user had a similar problem in 2004 and resolved the situation when she ran an update. I checked for updates, but none were availalbe, so that's not
-
Hi Experts, We have a strange issue, we have unchecked all the fields in personalize in Search master agreement and after saving, the personalize button disappeared. Please find the screenshot. How to recover the Personalize button? Thanks, Kushagra
-
Error in uploadXMLFiles. Trying again in 176.00 seconds or earlier.
I am not able to upload my xml files, I dont know what could be the reason. I am having 10202 agent and I have upgraded to 10203. It was talking to GC A, I have changed values to points to B in emd.properties. Now it's not able to upload the data...