CAn we write a query like this
CAn we write a query like this?
If not how can this be changed?
select col1,col2,col3.col4
from table 1
where col1,col2 in(select col1,col2 from table2)
Or it may be identical:
SQL> CREATE TABLE t1 (c INT NOT NULL);
Table created.
SQL> CREATE TABLE t2 (c INT NOT NULL);
Table created.
SQL> INSERT ALL
2 INTO t1 VALUES (rn)
3 INTO t2 VALUES (rn)
4 SELECT rownum AS rn FROM user_tables WHERE rownum <= 15;
30 rows created.
SQL> BEGIN
2 DBMS_STATS.GATHER_TABLE_STATS(user,'T1');
3 DBMS_STATS.GATHER_TABLE_STATS(user,'T2');
4 END;
5 /
PL/SQL procedure successfully completed.
SQL> SELECT * FROM t1
2 WHERE EXISTS
3 ( SELECT 1 FROM t2 WHERE c = t1.c )
4
SQL> @xplan
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 15 | 90 | 5 |
|* 1 | HASH JOIN SEMI | | 15 | 90 | 5 |
| 2 | TABLE ACCESS FULL | T1 | 15 | 45 | 2 |
| 3 | TABLE ACCESS FULL | T2 | 15 | 45 | 2 |
Predicate Information (identified by operation id):
1 - access("T2"."C"="T1"."C")
SQL> SELECT * FROM t1
2 WHERE c IN
3 ( SELECT c FROM t2 )
4
SQL> @xplan
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 15 | 90 | 5 |
|* 1 | HASH JOIN SEMI | | 15 | 90 | 5 |
| 2 | TABLE ACCESS FULL | T1 | 15 | 45 | 2 |
| 3 | TABLE ACCESS FULL | T2 | 15 | 45 | 2 |
Predicate Information (identified by operation id):
1 - access("T1"."C"="T2"."C")
Similar Messages
-
How can I write a query for this table?
Dear friends
I have a table with the following structur and data
ID Name Value
1 book 100
2 book 200
3 car 25
4 car 35
5 book 300
now I would like write a query with following out put
Name value
book 100 , 200 , 300
car 25 , 35
(with , Separator) (my oracle version is 10g)
thanksTry this,
SQL> WITH t AS(SELECT 'book' NAME, 100 VALUE FROM dual UNION ALL
2 SELECT 'book', 200 FROM dual UNION ALL
3 SELECT 'car', 25 FROM dual UNION ALL
4 SELECT 'car', 35 FROM dual UNION ALL
5 SELECT 'book', 300 FROM dual)
6 SELECT NAME, LTRIM (MAX (SYS_CONNECT_BY_PATH (VALUE, ',')), ',') VALUE
7 FROM (SELECT NAME, VALUE, ROW_NUMBER () OVER (PARTITION BY NAME ORDER BY VALUE) rn FROM t)
8 START WITH rn = 1
9 CONNECT BY PRIOR rn + 1 = rn
10 AND PRIOR NAME = NAME
11 GROUP BY NAME;
NAME VALUE
book 100,200,300
car 25,35
2 rows selected.
SQL> G. -
How can i write sql query for this result ?
Hello Dear,
Here is the script first.
CREATE TABLE ACC_TEST(
AD_ID NUMBER,
AD_NAME VARCHAR2(50),
AD_SPM_ID NUMBER);
/data are
Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (136,'Saleh Ahmed',129);
Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (142,'Hamidur Rahman',136);
Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (124,'Jasim Uddin',null);
INSERT INTO ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) VALUES (129,'Sazib',124);I Need The Following Result When I Pass A Value Of Ad_Id. For Example I Pass 142 Then Result Should Be
Select Ad_Id,Ad_Name
From..
where ad_id=142
Ad_Id Ad_Name
136 Saleh Ahmed
129 Sazib
124 Jasim Uddin
If I Pass Ad_Id=136 Then Result Should Be
Ad_Id Ad_Name
129 Sazib
124 Jasim Uddin
If I Pass Ad_Id=129 Then Result Should Be
Ad_Id Ad_Name
124 Jasim Uddin Database 10G XE
Any help will be helpfulHi,
HamidHelal wrote:
WoW ! you acutely got my point. How did you understand that ? lLuck guess. Guessing is usually not the best way to solve problems. It's usually faster and more reliable to say exactly what you want, as well as give an example.
ittle bit more i want to know, if i want to restrict the output not more then 2, what would be sql ?Now you're not even giviing an example!
Maybe you want something like this:
SELECT ad_id
, ad_name
FROM acc_test
WHERE LEVEL BETWEEN 2 AND 3 -- Changed
START WITH ad_id = :target_ad_id
CONNECT BY ad_id = PRIOR ad_spm_id
;which will show jsut the parent and the grandparent of the given row.
I do work with forms developer very much. Sql knowledge is as oracle sql book(cerfitication 9i). But this type of sql isn't available there.
where can i learn this type of sql ? Different sql then ordinary ?Certification is a different topic entirely.
There are books and web sites dealing with more advanced techniques. Sorry, I don't know any well enough to recommend them. Some authors (such as Tom Kyte) are consistently good.
Here are a couple of sites that explain CONNECT BY queries:
http://www.adp-gmbh.ch/ora/sql/connect_by.html
http://www.oradev.com/connect_by.jsp -
How can I write a query for this?
I have a table as below ,
room.........date.............inventory
A..............01/01.................5
A..............01/02.................5
A..............01/03.................5
A..............01/05.................5
A..............01/06.................5
A..............01/07.................8
I want the output as below
room.....begin_date........end_date......inventory
A............01/01.................01/03..........5
A............01/05.................01/06..........5
A............01/07.................01/07..........8
Is there any suggestion?
Thanks
nullwith x as
(select 'A' room, to_date ('01/01/2007', 'mm/dd/yyyy') d, 5 i from dual union all
select 'A' room, to_date ('01/02/2007', 'mm/dd/yyyy') d, 5 i from dual union all
select 'A' room, to_date ('01/03/2007', 'mm/dd/yyyy') d, 7 i from dual union all
select 'A' room, to_date ('01/04/2007', 'mm/dd/yyyy') d, 7 i from dual union all
select 'A' room, to_date ('01/05/2007', 'mm/dd/yyyy') d, 5 i from dual union all
select 'A' room, to_date ('01/06/2007', 'mm/dd/yyyy') d, 5 i from dual
select min (d)
, max (d)
, min (i)
from (
select room
, d
, i
, max (g) over (order by d) mg
from
(select room
, d
, i
, case when lead (i) over (partition by grp order by d) = i
then rownum
end g
from (
select room
, d
, i
, d - rownum grp
from x
order by d
group by mg -
How to write a query for this data??
In this table i have column dob which is DATE type,for example 12-jan-89 I want output like this
Year Day
12-jan-89 Thusrs_day
12-jan-90 Friday
upto
12-jan-14 sundaykrishnagopi wrote:
No not like that ,I want up to 2014 year
Ok, so lets say you have table like this
SQL> create table my_table(dob date);
Table created.
SQL> insert into my_table (dob) values( to_date('12-jan-1989', 'dd-mon-yyyy'));
1 row created.
SQL> commit;
Commit complete.
SQL> select * from my_table;
DOB
12-JAN-89
You can write a query like this
select dob + (level -1) dob
, to_char(dob + (level -1), 'fmDay') day_
from my_table
connect
by level <= (dob + interval '25' year) - dob + 1; -
Crystal Report XI: Can you write your query in SQL instead of using the GUI
Hello
In crystal report version XI, can you write your query in sqlplus and then use the crystal report designer to build your report instead of using the GUI . I would like to be able to go database and show sql query and open that query and make changes directly there, is that possible on this version, if yes is there a setting somewhere? Please let me know.
Thank you
alphaMoved to Database forum.
No you can no longer modify the SQL directly. Use a Command Object to enter the SQL directly.
Thank you
Don -
I want to place an image in my InDesign document that can work with an address like this (\Resources\Thumb) rather than this (C:\Users\JSmith\Desktop\InDesign thumbnail Test\001\Resources\Thumb) is this possible? In a nutshell I want to point the link to an image in a directory that uses just part of the address.
I know this is something you can do in Maya with linked files. I guess InDesign just isn't there yet.
MW Design - Yeah I think "Relative paths" is the right term! I want to create a Layout with an image in the center of the page - and then duplicate my folder structure with that file. With that, I want to replace the Linked image file with a diferent image file of the same name. In effect having multiple files of the same layout with different images. I hope that made sense. -
How can I write HTML code in this forums
Sorry but I didn't know where to post this thread.....
How can I write HTML code in this forums?Hello,
Every piece of code in your post should be wrapped with the forum tags [ code] and [ /code], without the blanks.
In case of the <a> tag, that is not enough. In this case, you have several options. The most elegant one is to use the entity name for the less-then sign - & lt; - without any spaces. Other options is to add a space between the less-then and the ‘a’ character (and make a note of it) or change the less-then character with a left bracket one.
When posting code, you should always use the forum preview option, just to make sure the forum software “understood” your code correctly.
Hope this helps,
Arie. -
How can I make a image like this one? (image in description)
Hi guys I need to know how can I make a image like this one http://img31.imageshack.us/img31/2710/69823211.gif
I need step by step instructions please. How can I animate it like that? Whats the font? Tell me everything please.To do a step by step instruction on here will take someone a very long time, as you havent really said at what level you are at.
On Youtube there are a lot of animation tutorials for PS. But essentially in this case you are moving that white streak across a few frames at a time.
The font might be found with the help of http://http://www.myfonts.com/WhatTheFont/ -
I write the code like this ...i didn't get output properly
Hi Experts,
I write the code like this ...i didn't get output properly......the selected file name is not copied to v_fname........
Points will be rewared...
tables : kna1.
parameters : P_FNAME type rlgrap-filename.
data : v_fname(200) type c . "lower case.
data : begin of itab occurs 0,
kunnr type kna1-kunnr ,
end of itab .
select kunnr from kna1 into table itab up to 50 rows .
at selection-screen on value-request for P_FNAME .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = v_fname
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = P_FNAME
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = 'v_fname'
FILENAME =
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.You are exporting field v_fname, not importing it. The field v_fname isn't for the file name anyway; field p_fname is for the file name. You also need to pass your file name to the function module GUI_DOWNLOAD for it to work.
- April King -
Scan line write-on effect like this...
I am looking to create a scan-line "write on" effect like this.
Patrick Sheffield originally posted the thread [here|http://discussions.apple.com/thread.jspa?messageID=634451򚹓].
I downloaded the projects but they didn't do exactly what the movie did.
This is the effect I am after:
[Scan line Movie|http://www.pistolerapost.com/viewing/analysis1.mov]
Thanks,,On the movie, the scanlines come down line by line, whereas in the project file, each line comes on randomly.
Also, on the movie there's a very nice brief glow going from side to side as each line is laid down.
When the scan lines go down they reveal an image. I guess you're using an image mask for that?
I looked for the project file that corresponds to the movie, but I couldn't find it.
There were two in the zip file: scanlinescreen , scanlinetext
^(ps: thanks for the "fun with" series - they've been helpful)^ -
How Can I write Query like this
My Dears:
I want to reduce some formula in my report by merge these formula in my query
I want to know how can I wrirte a query in query
for example
select empno,ename,(select sal from emp ee where ee.empno=mm.empno ) from emp mm
the previous query I know it not logic but I need the way
my DB 10G r2
thanks in advanceApart your remark nothing seems to be wrong with your query. Did you try it?
Regards
Etbin -
Hi friends,
I would like to know if this could be possible
we have some 20 business like bus_ind, bus_usa, bus_jap...
I have to do the below query each of the business
for bus_ind
SELECT COUNT(*)
FROM bus_ind
WHERE
workdate BETWEEN TO_DATE('01/01/2008','DD/MM/YYYY') AND TO_DATE('31/12/2008','DD/MM/YYYY') AND
workid NOT IN (6,7) AND
NOT EXISTS (SELECT 'X' FROM bus_ind WHERE somecol = workid);
instead of having 20 such query i was trying to see if there is a possibility to have a table like
shytest
id, tbl
1 bus_ind
2 bus_jap
3 bus_usa
and a single query like
SELECT COUNT(*)
FROM (select tbl from shytest where id=1)
WHERE
workdate BETWEEN TO_DATE('01/01/2008','DD/MM/YYYY') AND TO_DATE('31/12/2008','DD/MM/YYYY') AND
workid NOT IN (6,7) AND
NOT EXISTS (SELECT 'X' FROM bus_ind WHERE somecol = workid);
Thanks
-vishAccording to your requirnment there should be only one table for all the bussinesses with different partitions for all the bussiness.
For now you can also create one veiw for all the business.. & fire you all query on that
create or replace view business_view as
select 'bus_ind' as business_loc, col1, col2, ... from bus_ind union all
select 'bus_usa' as business_loc, col1, col2, ... from bus_usa union all
...Or you can also use Dynamic sql as all other are suggesting.
Regards
Singh -
Is there a way to query like this in Oracle 9i?
Hi!
Before starting, some constraints: I can't use store procedures for this task, and should use ANSI99 wherever possible.
Let's suppose a table like this:
CREATE TABLE ELEMENTS
(REG_NAME VARCHAR2(10) NOT NULL, --PK
ELM_ORDER NUMBER(3,0) NOT NULL, --PK
ELM_NAME VARCHAR2(10) NOT NULL,
ELM_SIZE NUMBER(3,0) NOT NULL
It's a table describing some structures (REG_NAME), which contains elements (ELM_NAME) with the order number in register (ELM_ORDER) and its size (ELM_SIZE)
Some sample data '; ' separated fields, columns at first line:
REG_NAME; ELM_ORDER; ELM_NAME; ELM_SIZE
TYPE1; 1; VERSION; 3
TYPE1; 2; CALLNBR; 6
TYPE1; 3; DATE; 8
TYPE1; 4; EVENTTYPE; 4
TYPE1; 5; EVENTDESCR; 100
TYPE1; 6; EVENTCODE; 2
TYPE1; 7; ATTNAME; 10
TYPE2; 1; VERSION; 3
TYPE2; 2; CALLNBR; 6
TYPE2; 3; DATE; 8
TYPE2; 4; SOLCODE; 2
TYPE2; 5; SOLDESCR; 100
TYPE2; 6; ATTNAME; 10
I'd like to query the DB such way I could obtain:
VERSION 3 1 4
CALLNBR 6 4 10
DATE 8 11 19
EVENTTYPE 4 20 24
EVENTDESCR 100 25 125
EVENTCODE 2 126 127
ATTNAME 10 128 138
I.e, I need to obtain for an specific REG_NAME (TYPE1 in the sample query result), the columns ELM_NAME, ELM_SIZE of all rows in ELEMENTS table ordered by ELM_ORDER and the sum of ELM_SIZE of the previous rows + 1 and the same sum added by ELM_SIZE of the current row.
I'm almost sure there's a way to do that but I couldn't figure out how.
TIA,
WB::If I understand your logic correctly, there are some calculation error in your sample result.
Don't know if this is possible using ANSI99, but in Oracle it is easy to do this:
SQL> CREATE TABLE ELEMENTS
2 (REG_NAME VARCHAR2(10) NOT NULL, --PK
3 ELM_ORDER NUMBER(3,0) NOT NULL, --PK
4 ELM_NAME VARCHAR2(10) NOT NULL,
5 ELM_SIZE NUMBER(3,0) NOT NULL
6 );
Tabel is aangemaakt.
SQL> insert into elements values ('TYPE1',1,'VERSION',3);
1 rij is aangemaakt.
SQL> insert into elements values ('TYPE1',2,'CALLNBR',6);
1 rij is aangemaakt.
SQL> insert into elements values ('TYPE1',3,'DATE',8);
1 rij is aangemaakt.
SQL> insert into elements values ('TYPE1',4,'EVENTTYPE',4);
1 rij is aangemaakt.
SQL> insert into elements values ('TYPE1',5,'EVENTDESCR',100);
1 rij is aangemaakt.
SQL> insert into elements values ('TYPE1',6,'EVENTCODE',2);
1 rij is aangemaakt.
SQL> insert into elements values ('TYPE1',7,'ATTNAME',10);
1 rij is aangemaakt.
SQL> select elm_name
2 , elm_size
3 , sum(elm_size) over (partition by reg_name order by elm_order) - elm_size + 1 elm_size_2
4 , sum(elm_size) over (partition by reg_name order by elm_order) + 1 elm_size_3
5 from elements
6 order by elm_order
7 /
ELM_NAME ELM_SIZE ELM_SIZE_2 ELM_SIZE_3
VERSION 3 1 4
CALLNBR 6 4 10
DATE 8 10 18
EVENTTYPE 4 18 22
EVENTDESCR 100 22 122
EVENTCODE 2 122 124
ATTNAME 10 124 134
7 rijen zijn geselecteerd.Regards,
Rob. -
Can anyone create a Query for this?
Can anyone help me to create a query for the followinf table info?
I have tried to use joins but no success.
Table Name: Org
ID Severity Status
1 Red New
2 Yellow New
3 Green Closed
4 Green Open
5 Yellow Closed
6 Red Closed
7 Red Closed
8 Red Open
9 Yellow New
10 Yellow Closed
The result of the query should look like this. The most important thing is that I want this result set in a single query and in this format.
Severity Total_Status Total_Closed
Red 4 2
Green 2 1
Yellow 4 2select severity,count(*) tot,sum(decode(status,'closed',1,0)) tot_closed
from org
group by severity;
Not tested..
Maybe you are looking for
-
Why can't I get any Actions to play?
All the loaded actions worked yesterday....none will play today. I can bring up yesterday's work and continue to work on the action run, however, when I closed that out and went to another project, I was unable to run any action loaded. I deleted t
-
I can send messages from my new mac mini to my powerbook, but now the other way. I am using wireless and have tried it with every combination of ichat and adium on each, but nothing changes. What's going on here?
-
I'm trying to return an Array like such: public T[] main = (T[]) new Object[100]; public int tracker = 0; public void getArray() { T[] temp = (T[]) new Object[tracker]; for(int x = 0; x < temp.length; x++) { temp[x] = ma
-
Padding character fields with zeros
Hello, I need to add zeros to the end of character fields TYPE C. I know i can use the conversion routines but that only works for numeric fields. Thanks
-
With my subscribtion i can't use skype
Since I registered and made subscription ,whenever i attempt a call I am directed to either subsribe or pay for skype credit , my one month bonus not withstanding