a quick pl/sql question

2004-01-16 Thread Guang Mei
Hi: In pl/sql, I want to add chr(10) into a string in every 70th position. The string can be up to 2000 characters long. The follwoing code works. But is there an even FASTER way to do this? Thanks. Guang --- declare pos number := 1; len number; buf varchar2(2000); x

Re: sql question

2004-01-13 Thread David Hau
Bear in mind though that the original query will only count rows where b.award_number is not null whereas this new query will count all rows in the result set. Regards, Dave [EMAIL PROTECTED] wrote: Can you change it to this query: SELECT count(1) FROM RF_BALANCE_T b, rf_security_by_dceid s

sql question

2004-01-12 Thread David Boyd
Hi List, I have following sql that runs in 1 sec: SELECT b.* FROM RF_BALANCE_T b, rf_security_by_dceid s WHERE (s.award_number = 'ALL') OR (b.award_number = s.award_number AND s.project_number = 'ALL') OR (b.award_number = s.award_number AND b.project_number= s.project_number AND s.task_number =

RE: sql question

2004-01-12 Thread DENNIS WILLIAMS
David - Can you post the EXPLAIN PLAN for both? Dennis Williams DBA Lifetouch, Inc. [EMAIL PROTECTED] -Original Message- Sent: Monday, January 12, 2004 1:14 PM To: Multiple recipients of list ORACLE-L Hi List, I have following sql that runs in 1 sec: SELECT b.* FROM RF_BALANCE_T b,

Re: sql question

2004-01-12 Thread eric king
Can you change it to this query: SELECT count(1) FROM RF_BALANCE_T b, rf_security_by_dceid s WHERE (s.award_number = 'ALL') OR (b.award_number = s.award_number AND s.project_number = 'ALL') OR (b.award_number = s.award_number AND b.project_number= s.project_number AND s.task_number = 'ALL')

RE: sql question

2004-01-12 Thread Kevin Toepke
That's fairly typical behavior. Try the following SELECT /*+ NO_MERGE(x) */ COUNT(*) FROM (your 1 second query) x Kevin -Original Message- Sent: Monday, January 12, 2004 2:14 PM To: Multiple recipients of list ORACLE-L Hi List, I have following sql that runs in 1 sec: SELECT b.*

Re: sql question

2004-01-12 Thread Mark Richard
Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such a case, you should destroy this message and

Re: sql question (RESEND)

2004-01-12 Thread Mark Richard
Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such a case, you should destroy this message and

Sql question

2004-01-07 Thread roland . skoldblom
Hallo, I have this sql query. I would like to change it so I could pick out the three forst three charachters in the between statements. How can I do that in the most simply way? and vgr in (between 101 and 101) and vgr in (between 104 and 104) order by Avdnr ,Datum1

Simple SQL Question

2003-12-18 Thread Jay Wade
Hello: I'm trying to figure out the new 9i outer joins. I can get a single table outer join working without any issues. But seem to keep getting errors when trying to do a two table outer join. I know it is just something with my syntax. Could anyone provide a quick sample, thanks in

RE: Simple SQL Question

2003-12-18 Thread Kevin Toepke
select a.emp, b.ValueA c.ValueB From base_table A RIGHT OUTER JOIN child_Table1 B ON b.emp = a.emp RIGHT OUTER JOIN child_Table2 C ON c.emp = a.emp -Original Message- Sent: Thursday, December 18, 2003 2:20 PM To: Multiple recipients of list ORACLE-L

RE: 8i pl/sql question

2003-12-16 Thread John Flack
Does myFunction1 often get called with the same arguments? In your example, the second argument is never repeated, but in the real thing, would the same second argument be likely to repeat? If myFunction1 gets the same arguments, will it always return the same value? If so, then it is a

RE: 8i pl/sql question

2003-12-16 Thread Guang Mei
The first argumant (myID) is a variable that is different every time the function gets called. The second argument is a hard code number (just as in my orginal message). So I guess I could not use DETERMINISTIC here. I have not heard of DETERMINISTIC before but I will take a look of this becuase

RE: 8i pl/sql question

2003-12-16 Thread Jamadagni, Rajendra
what does myfunction1() do? Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -Original

RE: 8i pl/sql question

2003-12-16 Thread Guang Mei
Below is the code for myfunction1 in the package, It calls a bunch of other functions, such as getBlastMatches, escapeGene, genes.gene2protein and addItem. Guang --- type blastMatch is record ( geneName gene.name%type, percent number ); function myfunction1 (seqid in number,

8i pl/sql question

2003-12-15 Thread Guang Mei
Hi: Oracle 8173 DB. I have a package funtion, part of it is doing something like this: utl_file.put_line(fpn, myFunction1(myID, 1)); utl_file.put_line(fpn, myFunction1(myID, 8)); utl_file.put_line(fpn, myFunction1(myID, 6)); utl_file.put_line(fpn, myFunction1(myID, 35));

RE: 8i pl/sql question

2003-12-15 Thread Jamadagni, Rajendra
can you return multiple values from a modified version of myfunction(1) ?? If so, then you can replace multiple calls by only one. And no, bulk binds is only within dml/select statements. Raj Rajendra dot Jamadagni

RE: pl/sql question and owa_pattern question

2003-11-21 Thread Stephane Faroult
Guang, I agree with your analysis, looping on characters is not the faster you can do, simply because there is a significant overhead (compared to C code for instance) in a language such as PL/SQL - which might be perfectly acceptable in some circumstances, much less so in very repetitive

RE: pl/sql question and owa_pattern question

2003-11-21 Thread Guang Mei
Hi Stephane: Thanks for your good suggestion. I compared the method you suggested and the orginal one and it indeed boosted the performance (in my simple test). However the ONLY problem I am having is that by doing TRANSLATE, I lost the original delimits. The new method (you suggested)

RE: pl/sql question and owa_pattern question

2003-11-21 Thread Guang Mei
Perl is a good tool for text processing. But our program is already written in pl/sql long time ago and there are intensive db calls in this pl/sql program. (text processing is only part of it). So I can not change that. BTW I did a comparison study a while ago for some of our pl/sql packages

RE: pl/sql question and owa_pattern question

2003-11-21 Thread Jamadagni, Rajendra
Guang, Well you are almost there ... you need fifo structure namely a pl/sql array 1. create a local pl/sql array to store the delimiter (store the ascii value of the delimiter to be safe) my_array (varchar2(5)) 2. as you find a delimiter insert into the first position in the array and

Re: pl/sql question and owa_pattern question

2003-11-21 Thread Mladen Gogala
PL/SQL is the fastest thing of them all when it comes to executing SQL commands, but there are things which simply aren't practical in 9.2 PL/SQL. Regular expression processing is one of those things. Fortunately, you can mix the two. Without DBI, perl scripts simply woudn't be very useful. Of

Re: pl/sql question and owa_pattern question

2003-11-21 Thread Daniel Hanks
Would extproc_perl fit well enough, though, until 10g is here? On Fri, 21 Nov 2003, Mladen Gogala wrote: PL/SQL is the fastest thing of them all when it comes to executing SQL commands, but there are things which simply aren't practical in 9.2 PL/SQL. Regular expression processing is one of

pl/sql question and owa_pattern question

2003-11-20 Thread Guang Mei
Hi: In my pl/sql program, I want to process each word in a string. The string is selected from a varchar2(300) column. The delimit that separates the words is not necessary space character. The definition of the delimit in this program is set as 1. Any character that is NOT AlphaNumerical (0-9,

Re: pl/sql question and owa_pattern question

2003-11-20 Thread Mladen Gogala
I don't know about PL/SQL but here is how I would get separate words from a big string: #!/usr/bin/perl -w use strict; my (@ARR); while () { chomp; @ARR = split(/[^0-9a-zA-Z_\.,]/); foreach (@ARR) { print $_\n; } } There is something called DBI and it can be used to

Re: Silly SQL Question

2003-11-18 Thread Vladimir Begun
Jacques, I checked your example, I think there are some issues here: 1. Original queries provided below do use merge join. 2. We could have missing indexes which can exist on real system. 3. Timings below is not a criteria -- after gathering statistics and creation an index on val this both

RE: Silly SQL Question

2003-11-17 Thread Bellow, Bambi
Jacques -- Huh? I thought the question was, give me all the usrs where there exists a record containing a 1,5, and 7. How can that return one record, when there are two users -- and only two users -- who have the 1,5,7 combination? The data provided shows that both GAP and GPA have a 1, 5 and

RE: Silly SQL Question

2003-11-17 Thread Jacques Kilchoer
The original question was show me the users who have ALL the values in the list but NOT MORE than the values in the list. -Original Message- Bellow, Bambi Huh? I thought the question was, give me all the usrs where there exists a record containing a 1,5, and 7. How can that

RE: Silly SQL Question

2003-11-17 Thread Michael Milligan
Just a guess: select distinct usr from xxx where (select count(*) from xxx group by Usr) = (select count(*) from xxx group by Usr, val) -Original Message- Sent: Thursday, November 13, 2003 3:29 PM To: Multiple recipients of list ORACLE-L

Re: Silly SQL Question

2003-11-17 Thread Daniel Fink
Using Bambi's table and values. Try this query, it's ugly but it works (kind of like the contributor...) Daniel 1 select o.usr, count(o.usr) 2 from (select distinct usr, val 3from gab 4where val in (1,5,7) 5 and usr not in (select usr 6

RE: Silly SQL Question

2003-11-17 Thread Alan Gano
Gabriel, How about this untested code? Alan. select usr from ( select usr, sum(decode(val,1,1,0)) look1, -- flag for 1 sum(decode(val,5,5,0)) look2, -- flag for 5 sum(decode(val,7,7,0)) look3, -- flag for 7

RE: Silly SQL Question

2003-11-17 Thread Gabriel Aragon
Ok, guys I have to apologize twice, First: the delay to answer your very kind emails, (you know the urgent problems dont let you time for the important ones) Second: maybe my question was not clear enough, ciertanly what Bambi says is what I need give me all the usrs where there exists a

Re: Silly SQL Question

2003-11-17 Thread Vladimir Begun
Jacques Kilchoer wrote: Mr. Begun: I'm not convinced that your answer is quite the right one. I've provided two solutions but I'm still confused :). Jacques, does that mean that I understand English and the original query was Ok? :) -- Vladimir Begun The statements and opinions expressed here are

RE: Silly SQL Question

2003-11-17 Thread Jacques Kilchoer
Mr. Begun, I didn't answer your comment about making the query work with the decode vs. using a user-written PL/SQL function because I wanted to compare timings for both. I created a table with 200,000 rows and compared the VB (Vladimir Begun) query to the JRK (my) query. The runtimes were

Re: Silly SQL Question

2003-11-17 Thread Vladimir Begun
Jacques, you can use my first name -- Mr. is too official for this list :). You have modified the query, however I would suggest you to check execution plan (and present it here) and remove LENGTH(TRANSLATE(:list, ',0123456789-E', ',')) by replacing it using number of elements in the list i.e.,

RE: Silly SQL Question

2003-11-14 Thread Bellow, Bambi
Why not do it like this... select usr from gab where val=1 intersect select usr from gab where val=5 intersect select usr from gab where val=7; -Original Message- Sent: Thursday, November 13, 2003 7:35 PM To: Multiple recipients of list ORACLE-L Mr. Begun: I'm not convinced that your

RE: Silly SQL Question

2003-11-14 Thread Jacques Kilchoer
Yes, your query was much better. I keep on forgetting about those analytic functions. Shame on me. I still think using a PL/SQL function to be able to easily change the IN list is worth the time and trouble. Plus it makes the explain plan is more interesting with the str_to_tbl function, you

RE: Silly SQL Question

2003-11-14 Thread Jacques Kilchoer
-Original Message- Bellow, Bambi Why not do it like this... select usr from gab where val=1 intersect select usr from gab where val=5 intersect select usr from gab where val=7; Because that way you would get the wrong answer. With the sample data as kindly provided by

Re: Silly SQL Question

2003-11-14 Thread Vladimir Begun
Jacques Jacques Kilchoer wrote: I still think using a PL/SQL function to be able to easily change the IN list is worth the time and trouble. If the given list is created properly, which I think it's a must in this case, one would not need to use PL/SQL, the task can be solved in SQL only. Below

Silly SQL Question

2003-11-13 Thread Gabriel Aragon
I have a table with like this: Usr val -- GAP 1 GAP 5 GAP 7 JKL 8 JKL 5 I need a query that returns the user (GAP o JKL) that has ALL the values in a list. Example: Having the list: 1,5,7 the result will be GAP, but with the values 1,5 or 1,5,7,8 there will be no result. select

Re: Silly SQL Question

2003-11-13 Thread Stephane Faroult
Gabriel Aragon wrote: I have a table with like this: Usr val -- GAP 1 GAP 5 GAP 7 JKL 8 JKL 5 I need a query that returns the user (GAP o JKL) that has ALL the values in a list. Example: Having the list: 1,5,7 the result will be GAP, but with the values 1,5 or

RE: Silly SQL Question

2003-11-13 Thread Aponte, Tony
Here's one solution. SELECT usr FROM xxx GROUP BY usr HAVING SUM(DECODE(val,1,1,0)) 0 AND SUM(DECODE(val,5,1,0)) 0 AND SUM(DECODE(val,7,1,0)) 0 HTH Tony Aponte -Original Message- Sent: Thursday, November 13, 2003 5:05 PM To: Multiple recipients of list ORACLE-L I have a

RE: Silly SQL Question

2003-11-13 Thread Aponte, Tony
Sorry I missed one. Try this. SELECT usr FROM bogus GROUP BY usr HAVING SUM(DECODE(val,1,1,0)) 0 AND SUM(DECODE(val,5,1,0)) 0 AND SUM(DECODE(val,7,1,0)) 0 AND SUM(DECODE(val,1,0,5,0,7,0,val)) = 0 Tony Aponte -Original Message- Sent: Thursday, November 13, 2003 5:30 PM

Re: Silly SQL Question

2003-11-13 Thread Vladimir Begun
Gabriel DROP TABLE gab; CREATE TABLE gab (usr VARCHAR2(10) NOT NULL, val NUMBER NOT NULL --, CONSTRAINT gab$uq UNIQUE (usr, val) ); INSERT INTO gab VALUES('GAP', 1); INSERT INTO gab VALUES('GAP', 5); INSERT INTO gab VALUES('GAP', 7); INSERT INTO gab VALUES('JKL', 8); INSERT INTO gab

RE: Silly SQL Question

2003-11-13 Thread Jacques Kilchoer
Mr. Begun: I'm not convinced that your answer is quite the right one. I tried INSERT INTO gab VALUES ('GAP', 9) ; and then this query SELECT usr FROM ( SELECT DISTINCT usr, val FROM gab ) WHERE val IN (1, 5, 7) GROUP BY usr HAVING COUNT(*) = 3 -- number of elements

Re: Silly SQL Question

2003-11-13 Thread Vladimir Begun
Jacques Yes, probably, you are right. I've overlooked example section, given by Gabriel. DROP TABLE gab; CREATE TABLE gab (usr VARCHAR2(10) NOT NULL, val NUMBER NOT NULL); INSERT INTO gab VALUES('GAP', 1); INSERT INTO gab VALUES('GAP', 5); INSERT INTO gab VALUES('GAP', 5); INSERT INTO gab

interesting dynamic pl/sql question

2003-10-09 Thread rgaffuri
Im on 8.1.7. Is it possible to do something like this? Im getting errors: create or replace procedure myproc is TYPE myRecord is RECORD ( field_1 number, field_2 number); TYPE storageArray IS TABLE OF myRecord INDEX BY BINARY_INTEGER; myStorageArray storageArray; i

RE: interesting dynamic pl/sql question

2003-10-09 Thread Igor Neyman
You should be getting errors, because PL/SQL inside execute immediate knows nothing about mystorageArray (or i for that matter) declared in your stored procedure. Probably, you could get by using package variables (and referring to them properly: package_name.var_name, specifically inside your

RE: interesting dynamic pl/sql question

2003-10-09 Thread Jamadagni, Rajendra
Title: RE: interesting dynamic pl/sql question Ryan, what errors are you getting? Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can

Re: interesting dynamic pl/sql question

2003-10-09 Thread AK
I think ' begin mystorageArray.field_''i'' := 1; end; '; will not recongize mystoragearray as a variable . -ak - Original Message - To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Sent: Thursday, October 09, 2003 11:49 AM Im on 8.1.7. Is it possible to do

interesting sql question

2003-09-29 Thread rgaffuri
Im taking a database theory class(no I dont need help with my homework). There is an interesting query in the book that I have never seen posed before. The solution would be hideously slow if there was even a moderate amount of data in the tables. How would you write it? Given 3 tables: and

RE: interesting sql question

2003-09-29 Thread Mercadante, Thomas F
Ralph, Assuming that there is no history in the BIDS table (meaning that there are no old records indicating a bid recorded last year), I think the following would work just fine. select name from person, (select distinct sid, count(*) bid_count from bids group by sid) bids where

RE: interesting sql question

2003-09-29 Thread Stephane Faroult
- --- Original Message --- - From: [EMAIL PROTECTED] To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Sent: Mon, 29 Sep 2003 05:19:39 Im taking a database theory class(no I dont need help with my homework). There is an interesting query in the book that I have never

RE: interesting sql question

2003-09-29 Thread Khedr, Waleed
select pn.name from (select /*+ no_merge */ count(*) boat_cnt from boat) bt, bid bd, person pn where bd.sid = pn.sid group by pn.name, boat_cnt having count(bd.boat_id) = boat_cnt Waleed -Original Message- Sent: Monday, September 29, 2003 9:20 AM To: Multiple recipients of

Re: RE: interesting sql question

2003-09-29 Thread rgaffuri
From: Stephane Faroult [EMAIL PROTECTED] Date: 2003/09/29 Mon AM 09:59:39 EDT To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Subject: RE: interesting sql question - --- Original Message --- - From: [EMAIL PROTECTED] To: Multiple recipients of list ORACLE

RE: RE: interesting sql question

2003-09-29 Thread Jamadagni, Rajendra
Title: RE: RE: interesting sql question Here is an attempt ... select p.* from persons p where sid in (select sid, count(bid) from bids group by sid having count(sid) = (select count(boad_id) from boats)) / You wanted to find all persons who have booked all boats ... add criteria

RE: interesting sql question

2003-09-29 Thread Chelur, Jayadas {PBSG}
This would eliminate duplicate bids on the same boat by the same person SELECT p.* FROMPERSON p, ( SELECT COUNT(*) boat_count FROMBOAT ) c, ( SELECT sid, COUNT(DISTINCT boat_id) bid_count FROMBIDS GROUP BY sid

RE: RE: interesting sql question

2003-09-29 Thread rgaffuri
a user may request the same boat more than once. not sure that work. From: Jamadagni, Rajendra [EMAIL PROTECTED] Date: 2003/09/29 Mon AM 10:34:53 EDT To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Subject: RE: RE: interesting sql question Here is an attempt ... select p

RE: RE: interesting sql question

2003-09-29 Thread Jamadagni, Rajendra
Title: RE: RE: interesting sql question Hey ... the question wasn't complete ... give us the full statement of the question ... g Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed

Re: RE: interesting sql question

2003-09-29 Thread rgaffuri
: RE: interesting sql question Ralph, Assuming that there is no history in the BIDS table (meaning that there are no old records indicating a bid recorded last year), I think the following would work just fine. select name from person, (select distinct sid, count(*) bid_count from

RE: RE: interesting sql question

2003-09-29 Thread rgaffuri
, Thomas F [EMAIL PROTECTED] Date: 2003/09/29 Mon PM 12:29:40 EDT To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Subject: RE: RE: interesting sql question yeah! I think it *is* homework :) Tom -Original Message- Sent: Monday, September 29, 2003 12:10 PM

is this a good practice...pl/sql question

2003-09-17 Thread Steve McClure
Allright I am making some changes to some pl/sql code that handles batch inserts into the database. I am making changes to correct an error where our clients are sending us data with invalid state information in their address fields. A constraint prohibits the insert with records with invalid

RE: is this a good practice...pl/sql question

2003-09-17 Thread Goulet, Dick
Steve, It may be old fashion code, but if it works within the time frame it needs to run in, why spend time recoding? At any rate, I don't see a problem. Dick Goulet Senior Oracle DBA Oracle Certified 8i DBA -Original Message- Sent: Wednesday, September 17, 2003 4:05 PM To:

RE: is this a good practice...pl/sql question

2003-09-17 Thread Jamadagni, Rajendra
Title: RE: is this a good practice...pl/sql question Steve, Nothing wrong with setting xrec.state to null ... your developer is avoiding hard coding of NULL in the insert statement. In fact if this is working fine then only thing I'd try to change is bulk inserts instead of one by one

Re: is this a good practice...pl/sql question

2003-09-17 Thread Stephane Faroult
Steve McClure wrote: Allright I am making some changes to some pl/sql code that handles batch inserts into the database. I am making changes to correct an error where our clients are sending us data with invalid state information in their address fields. A constraint prohibits the insert

RE: is this a good practice...pl/sql question

2003-09-17 Thread Steve McClure
Keeping aside all considerations about the loop, I see no problem here. The cursor variable is just short-hand notation for defining a table%ROWTYPE - you are not modifying some hidden Oracle internal state if this is what you are fearing. No 'mutating cursor', if I guess you correctly. I

RE: is this a good practice...pl/sql question

2003-09-17 Thread Jamadagni, Rajendra
Title: RE: is this a good practice...pl/sql question Yes it is a good practice when required. Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any

SQL question : How to retrieve the File_name without Directorie P

2003-07-23 Thread NGUYEN Philippe (Cetelem)
Title: SQL question : How to retrieve the File_name without Directorie Path ? Hi Gurus! a very simple problem for You :I just want to retrieve the .dbf name from file_name column in dba_data_files. eg :'/oracle/d0/data/user.dbf' -- user.dbf Maybe using translate function ? Thank in advance

Antw: SQL question : How to retrieve the File_name without

2003-07-23 Thread Guido Konsolke
Hi Philippe, eat this: select substr('/oracle/d0/data/user.dbf',instr('/oracle/d0/data/user.dbf','/',-1)+1) from dual; hth, Guido [EMAIL PROTECTED] 23.07.2003 09.59 Uhr Hi Gurus! a very simple problem for You :I just want to retrieve the .dbf name from file_name column in dba_data_files.

RE: Antw: SQL question : How to retrieve the File_name without

2003-07-23 Thread Igor Neyman
eat this: Is it chewable? -:) Igor Neyman, OCP DBA [EMAIL PROTECTED] -Original Message- Guido Konsolke Sent: Wednesday, July 23, 2003 3:14 AM To: Multiple recipients of list ORACLE-L Hi Philippe, eat this: select

RE: RE: Antw: SQL question : How to retrieve the File_name

2003-07-23 Thread Guido Konsolke
Hi Igor, yes, it is. But it would be better if we all swallow the use of the builtin functions. My weaknesses are with analytic functions. I would give my colleague's right arm for getting into them ;-)) Greetings, Guido [EMAIL PROTECTED] 23.07.2003 15.54 Uhr eat this: Is it chewable?

Re: SQL question : How to retrieve the File_name without Directorie P

2003-07-23 Thread Daniel Fink
Phillipe, Look at using INSTR and SUBSTR to calculate the position of the last / and work from there. Daniel NGUYEN Philippe (Cetelem) wrote: Hi Gurus! a very simple problem for You :I just want to retrieve the .dbf name from file_name column in dba_data_files. eg

SQL question - crosstab in oracle

2003-07-08 Thread Stephen . HODGKINSON
Hi I have a table with the following structure. CHECK_DATE DATE PHYRDS NUMBER(20) PHYWRTSNUMBER(20) PHYBLKRD

Re: SQL question - crosstab in oracle

2003-07-08 Thread Jay Wade
There are several ways to handle this. If you do a search for pivot on AskTom you will get a good sampling of them. From: [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Subject: SQL question - crosstab in oracle Date: Tue, 08 Jul 2003 06

RE: SQL Question

2003-04-04 Thread Chelur, Jayadas {PBSG}
Hi Madhavan, You are always welcome. I had to write a similiar one some time back and I remember it was quite a task then. Thankfully I had a head start this time !. Hope you get the stuff sorted out. Glad to be of help ... Regards, Jayadas -Original Message- Sent: Thursday, April 03,

SQL Question

2003-04-03 Thread Madhavan Amruthur
Hi, Sorry for reposting. Just wanted to put in a subject... I have been grappling with this for sometime and thought it will be best for others to take a look at it. I have a table a_user_groups USER_ID SECURITY_GROUP_ID GROUP_ID -- - -- 1005

RE: SQL Question

2003-04-03 Thread Chelur, Jayadas {PBSG}
Madhavan, I have created a similiar table and inserted the data as follows :- = CREATE TABLE UT ( U NUMBER(4), S NUMBER(4), G NUMBER(4) ); INSERT INTO UT VALUES(2005,1012,1010); INSERT INTO UT VALUES(2005,1012,1011); INSERT

RE: SQL Question

2003-04-03 Thread Madhavan Amruthur
Hi Jaydas, Thanks for the reply. It gives me a good starting point to go with. The query handles cases where there are multiple rows. For eg: U=2006 has G=1010 and S=1013. If there were another U=2010 with same G=1010, then a rum through the query would generate a S=1012 for this combination also

RE: a DIFFERENT sql question

2003-03-14 Thread Aponte, Tony
Title: RE: a DIFFERENT sql question SELECT DISTINCT t1.category CAT ,t2.type TYP ,SUM(DISTINCT t1.amount1) OVER(PARTITION BY t1.category) Sum1 ,SUM(t2.amount2) OVER(PARTITION BY t1.category, t2.type) Sum2 FROM t1 ,t2 WHERE t1.mykey1 = t2.mykey1 / CAT TYP SUM1 SUM2 AA x 8 27 AA

A SQL Question

2003-03-13 Thread Deshpande, Kirti
Hi SQL Developers, I have a table as follows: Col1 Col2 AB CD EF GH BA EF CD HG With a PK on (Col1, Col2). How do I write a SQL script to get following result? Col1Col2 AB B

Re: A SQL Question

2003-03-13 Thread Igor Neyman
Kirti, I think, you have typo (duplicate rows), when describing data inserted into table, considering PK on (col1, col2). Shouldn't it be: SQLWKS create table test( 2 col1 varchar2(10), 3 col2 varchar2(10), 4 constraint PK_TEST primary key (col1, col2)); Statement processed.

RE: A SQL Question

2003-03-13 Thread DENNIS WILLIAMS
Kirti - I haven't had enough coffee this morning, so it seems to me the obvious solution is an order by clause. What am I missing here? Dennis Williams DBA, 40%OCP, 100% DBA Lifetouch, Inc. [EMAIL PROTECTED] SQL select * from test; C C - - A B C D E F G H B A F E D C H G 8 rows selected.

RE: A SQL Question

2003-03-13 Thread Whittle Jerome Contr NCI
Title: RE: A SQL Question SELECT table.Col1, table.Col2 FROM table UNION SELECT table.Col2, table.Col1 FROM table ORDER BY table.Col1; Actually you might not even need the ORDER BY Jerry Whittle ASIFICS DBA NCI Information Systems Inc. [EMAIL PROTECTED] 618-622-4145

Re: A SQL Question

2003-03-13 Thread mkb
Hi Kirti, Just a clarification: PK on col1, col2 but you have duplicates C,D and E,F. If the dups are removed, is the porblem still valid? mohammed --- Deshpande, Kirti [EMAIL PROTECTED] wrote: Hi SQL Developers, I have a table as follows: Col1 Col2 AB C

RE: A SQL Question

2003-03-13 Thread Stephane Faroult
Hi SQL Developers, I have a table as follows: Col1 Col2 AB CD EF GH BA EF CD HG With a PK on (Col1, Col2). How do I write a SQL script to get following result? Col1Col2 AB B

RE: A SQL Question

2003-03-13 Thread Whittle Jerome Contr NCI
Title: RE: A SQL Question Kirti, It's impossible to have a primary key as you have duplicate values. C-D and E-F both have dupes. If there should be D-C and F-E, a simple Order By Col1 would do the trick. Jerry Whittle ASIFICS DBA NCI Information Systems Inc. [EMAIL PROTECTED] 618-622

RE: A SQL Question

2003-03-13 Thread Deshpande, Kirti
:25 AM To: oracle list (E-mail) Subject: A SQL Question Hi SQL Developers, I have a table as follows: Col1 Col2 AB CD EF GH BA EF CD HG With a PK on (Col1, Col2). How do I write a SQL

Re: A SQL Question

2003-03-13 Thread Darrell Landrum
Hi Kirti, This isn't possible. The primary key won't allow for the duplicate values. There are 2 records of C,D and 2 records of E,F. Darrell [EMAIL PROTECTED] 03/13/03 07:23AM Hi SQL Developers, I have a table as follows: Col1 Col2 AB CD EF G

Re: A SQL Question

2003-03-13 Thread mkb
Assuming dups can be deleted, here's my humble attempt: select col1, col2 from t order by col1, col2; Col1 Col2 -- AB BA CD EF GH HG 6 rows selected. select col1, col2 from t union select col2, col1 from t ; Col1 Col2 -- AB BA CD DC EF F

Re: A SQL Question

2003-03-13 Thread Igor Neyman
Kirti, I tried to reply to your direct e-mail, but your mail-server is very strict and considered my message to be Unsolicited Bulk Email. What I was trying to say is: Oracle-l list behaves very strangely (sometimes), I'm still waiting to see corrected version of your question. And actually I

Re: A SQL Question

2003-03-13 Thread Ron Rogers
Kirti, Would not and order by col1,col2 give the resulting set you want? Is the data shown correct? you have C,D twice. I think you ment C,D and D,C. Ron [EMAIL PROTECTED] 03/13/03 08:23AM Hi SQL Developers, I have a table as follows: Col1 Col2 AB CD E

RE: A SQL Question

2003-03-13 Thread Mercadante, Thomas F
Kirti, is this a trick question, or am I missing something? select col1, col2 from table order by col1 Tom Mercadante Oracle Certified Professional -Original Message- Sent: Thursday, March 13, 2003 8:24 AM To: Multiple recipients of list ORACLE-L Hi SQL Developers, I have a

RE: A SQL Question

2003-03-13 Thread Naveen Nahata
Will 'ORDER BY col1' not do?? ;-) Atleast in this example it does. What are exact requirements? Regards Naveen -Original Message- Sent: Thursday, March 13, 2003 6:54 PM To: Multiple recipients of list ORACLE-L Hi SQL Developers, I have a table as follows: Col1 Col2

RE: A SQL Question

2003-03-13 Thread Deshpande, Kirti
. Sorry about this little problem. I will post my Corrected SQL Question again... Thanks. - Kirti -Original Message- Sent: Thursday, March 13, 2003 9:04 AM To: Multiple recipients of list ORACLE-L Kirti, I tried to reply to your direct e-mail, but your mail-server is very strict

RE: A SQL Question

2003-03-13 Thread Nelson, Allan
Select * from my_table order by col1; -Original Message- Sent: Thursday, March 13, 2003 7:24 AM To: Multiple recipients of list ORACLE-L Hi SQL Developers, I have a table as follows: Col1 Col2 AB CD EF GH BA EF C

Corrected SQL Question...

2003-03-13 Thread Deshpande, Kirti
Okay, let me do this right this time,... (Now that I have my hot tea going;) Here is the test data: SQL select c1,c2 from cp; C1 C2 --- --- AUS DAL AUS HOU DAL AUS DAL HOU DAL LIT DAL XYZ HOU AUS HOU DAL HOU LIT HOU XYZ LIT DAL C1 C2 --- --- LIT HOU XYZ DAL XYZ HOU 14 rows selected. SQL

Re: A SQL Question

2003-03-13 Thread Wolfgang Breitling
Title: Re: A SQL Question SQL select A.c1, B.c2 2 from (select col1 c1, rownum r from tbl order by col1) A 3 , (select col2 c2, rownum r from tbl order by col2) b 4 where a.r = b.r 5 union all 6 select B.c2, A.c1 7 from (select col1 c1, rownum r from tbl order by col1) A 8 , (select

a DIFFERENT sql question

2003-03-13 Thread STEVE OLLIG
since we're having fun with SQL today - here's one that's hurting my brain at the moment. I need to sum columns at 2 different groupings in my resultset. The first select is perfect; the 2nd is where i have trouble; but i know i can do stuff like the 3rd example. How do I get the 2nd one to

Corrected SQL Question...

2003-03-13 Thread Deshpande, Kirti
Okay, let me do this right this time,... (Now that I have my hot tea going;) Here is the test data: SQL select c1,c2 from cp; C1 C2 --- --- AUS DAL AUS HOU DAL AUS DAL HOU DAL LIT DAL XYZ HOU AUS HOU DAL HOU LIT HOU XYZ LIT DAL C1 C2 --- --- LIT HOU XYZ DAL XYZ HOU 14 rows selected. SQL

Re: Corrected SQL Question...

2003-03-13 Thread rgaffuri
EST To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Subject: Corrected SQL Question... Okay, let me do this right this time,... (Now that I have my hot tea going;) Here is the test data: SQL select c1,c2 from cp; C1 C2 --- --- AUS DAL AUS HOU DAL AUS DAL HOU DAL LIT

  1   2   3   4   5   >