SQL & PL/SQL :: Number Casting To Pull Name
Feb 1, 2012
I have two tables. How I can cast Book Collection_ID number to Book_Name?
Select A.BookCollection_ID from Bookpart A, BookName B where A.BookPart_ID = B.BookPart_ID
OutPut
1,2
Expected OutPut
ToyBook,FunBook
We need to separate 1,2 and extract Book_NAME from Book Part table.
i.e 1 as ToyBook and 2 as FunBook ?
1.CREATE TABLE BookPart (
BookPart_ID INTEGER NOT NULL,
LIMIT_MAX VARCHAR2 (255),
BookCollection_ID INTEGER,
PRIMARY KEY (BookPart_ID )
2.CREATE TABLE BookName (
BookName_ID INTEGER NOT NULL,
BookPart_ID INTEGER,
Business_ID INTEGER,
Book_NAME VARCHAR2 (255),
PRIMARY KEY (BookName_ID )
View 17 Replies
ADVERTISEMENT
May 9, 2013
I want to start by saying I am brand new to SQL. I have an access database linked to my oracle and am trying to query a very specific set of data and I can't seem to narroe it down. I have 244,000 lines in the DB and I'm trying to find items on a specific trype of vendor agreement. I may have the same item on multiple agreements. ex 1-, 1a-, 2-,2a-,3-,3a-,4-,4a-,5-,5a-,6-,6a-,7-,7a-,8-,8a-.
each item by agreement is on it's own line.
ex.
item ven_agrmt_ref
233 1a-xxx
233 4-xxx
233 4a-xxx
255 4a-xxx
I need to find a way to select just items that appear on a 4- or 4a- and no other agreement reference. The query I did so far pulls all of the 4- and 4a- agreements but will also pull items,like #233 in the example above, but not showing the 1a- agreement. I need it to overlook that item eventhough it does appear on the agreement I am looking for but also has an agreement I am not. the statement I am using right now is:
SELECT item, ven_item, ven_agrmt_ref, base_cost, vendor
FROM "all items by agreement"
WHERE ven_agrmt_ref >= '4'
ORDER BY item
View 3 Replies
View Related
Oct 9, 2013
I am having trouble trying to pull the next value from a query based on a where clauseThe query I am using is:
Declare nextID NUMBER(22);BEGINselect lag(ref_contact_id, 1,0) OVER (ORDER BY ref_contact_id)into nextID from (select ref_contact_id,lead(ref_contact_id, 1,0) OVER (order BY ref_contact_id) as "NextNbr", lag(ref_contact_id, 1,0) OVER (order BY ref_contact_id) as "LastNbr"from (select rc.ref_contact_id from REF_CONTACT rc order by FIRST_NAME ))where ref_contact_id = 793 ;END; The returned value is 0.
I understand why but not how to pull the next value base on a particular ref_contact_id.
View 1 Replies
View Related
Aug 9, 2012
In the database we use for transfer articulation, there are numerous tables delivered with the product. The institution decided not to use certain fields, and all instances of those fields have no data. In other words, there might be a field in the table called INSTCD, but no records in the table have ever inserted any data into that particular field. In the table there are thousands of records, and we don't necessarily know which of the fields have never been used (no list has been retained and no one who initially was involved in the decisions is available to ask), as there are multiple fields in each table. How can I write a query that pulls only the fields in the table that contain data. In the example below, the SHRTRIT table contains a field called ACTIVITY_DATE, but there is no data in any record in that particular field, so I don't want it to show up on the output. In this particular case, I KNOW not to pull this field in a SELECT, but in a case where there might be 130,000 records and I DON'T know if a field has records in it, how could I do that?
if the question I'm asking doesn't make sense and I'll attempt to word it better.
create table SHRTRIT
(
SBGI_CODE VARCHAR2(6) NOT NULL,
SBGI_DESC VARCHAR2(10),
ACTIVITY_DATE VARCHAR2(10)
)
[Code]....
View 9 Replies
View Related
May 3, 2007
I need to pull the 3 newest articles in a news table. Here's a list of rows including dates:
SQL> SELECT newsid, dateadded, ROWNUM from news ORDER BY dateadded DESC;
NEWSID DATEADDED ROWNUM
---------- --------- ----------
61 02-MAY-07 17
47 01-MAY-07 9
46 01-MAY-07 8
45 01-MAY-07 7
44 01-MAY-07 6
43 01-MAY-07 5
42 01-MAY-07 12
41 01-MAY-07 11
[code]....
This seems like such a basic thing to do.
View 6 Replies
View Related
Aug 28, 2013
I need to pull most recent status from a table with date field in the case statement.
status date
1 08/28/2013
2 05/12/2-13
3 02/11/2013
I need the status result of 1 (i.e most recent) and have to do in case statement only. Not interested in the date field in the final result.
View 1 Replies
View Related
Oct 19, 2010
I want to move data between two instances and recommended we create a local database link to PULL data from remote database located here (supplier on site) but they want to PUSH data to us. I thought you could only PULL data over a database link but then read the link [URL] where PUSH is considered ? I was going to use standard creatas like create table A as select * from table A@<remote_db_link> which works well and fast ( tried and tested) but some are saying they think PUSH quicker/better ?
we do have data "PUSH" already but this does not use a db link - effectively it calls a local proceedure here and passes a row of data and is slow ie for a 1000 row table to be pushed to us we have our local proceedure called 1000 times.
I have always suggested a PULL with db_link as the fastest method - any proof OR info on a fast PUSH method ( that is quicker than PULL ) ? can you REALLY push ?
View 2 Replies
View Related
May 3, 2010
I'm needing to pull data into a cursor, then split this data into 3 different tables, each having the same number of rows and a select number of columns from the original. i can pull the data, but then i can only access it one row at a time via FETCH, then i can't load into the 3 new CURSORS one row at a time.
View 11 Replies
View Related
Dec 30, 2011
I am writing a query where I'd like to pull one year's worth of data. Ideally I want to prompt for the END DATE and have the query go back in time one year from that date.
Here is what I've got after doing some research online... but It's not quite working for me.
select *
from mrtcustomer.profile
where reg_type = 'B'
and contact_type = 0
and active_ind = 'Y'
[code].....
View 4 Replies
View Related
Mar 26, 2013
I'm trying to pull all the degrees into a table based on which institution is selected. If institution is 'AAA' or 'BBB' then pull ACAD_PLAN, DESCR by ACAD_PROG where ACAD_PROG >= some value and <= some other value.
If institution is 'CCC' then pull ACAD_PLAN, DESCR by institution regardless of ACAD_PROG.
Something like
INSERT INTO table
SELECT
'value_a'
[Code].....
I don't have this formatted right cause it keep telling me missing keywords.
View 1 Replies
View Related
Sep 9, 2011
SQL Plus version Oracle8 Enterprise Edition Release 8.0.5.0.0 - Production
PL/SQL Release 8.0.5.1.0 Production
Forms Version : 6i
Reports Version: 6i
O/S : Microsoft Windows Xp professional Version 2002 Service Pack 3
With regards to the above version description here is my query. I have a form which calls report it accepts various parameters like date between, appeal and so on . I want the report to be restricted to the date parameter as passed by the user.Here is my coding which runs report
Declare
Pl_id ParamList;
where_cond varchar2(2500);
Begin
------------Appeal------------------
if
upper(ltrim(rtrim(:appeal)))<> 'ALL' then
where_cond:= where_cond ||'and tbl_donation.appeal_code='||ltrim(rtrim(:blk_ihelp.appeal_code));
else
where_cond:= where_cond||' and tbl_donation.appeal_code is not null';
end if;
-------------Date Option----------------
if
:date_option is not null then
if
:date_option = 'BETWEEN'then
where_cond:=' and tbl_donation.donation_date between '''||ltrim(rtrim(:fdate))||''' and ''' ||ltrim(rtrim(:tdate))||'''';
else
where_cond:=' and tbl_donation.donation_date '||:date_option||''''||ltrim(rtrim(:fdate))||'''';
end if;
end if;
--------------Country-------------------
if
upper (ltrim(rtrim(:country))) <> 'ALL'then
where_cond:= where_cond||'and tbl_donation.country_code='||ltrim(rtrim(:blk_ihelp.country_code));
else
where_cond:= where_cond||'and tbl_donation.country_code is not null';
end if;
-------------Contact Code---------------
if
:contact_code is not null then
if
:contact_code = 'BETWEEN'then
[Code]....
View 1 Replies
View Related
Jan 29, 2009
I have an Oracle 10g database, on the App Serv I have an image file that has 20,000 .jpg files that has an id number as each image name.I have successfully queryed the image file and posted one image to my web page matching the image id number.
sample:
select substr(spriden_last_name,1,20)||', '||
substr(spriden_first_name,1,20)||' '||
substr(spriden_mi,1,1) stname,
'<img src = "/images/&1..JPG" width="400" height="400"/>' pic
from spriden
where spriden_id = '&1'
/
the &1 is the matching id number that is input from the user.My task now is to select multiple images using a department field in the spriden table to pull the needed id numbers.I have not been successful in the proper format to pass the id number to the <img src field.
View 4 Replies
View Related
Mar 9, 2011
I have a staging table and a target table. How do I pull in last loaded data from staging table to target table?
View 4 Replies
View Related
Jan 26, 2010
i am using oracle developer 6i report builder i required this type of query
example
if (:page number LIKE '1')
then
srw.set_text_color('darkred');
end if;
return (TRUE);
end;
but page number is not my table database item how can i use builtan page &<pagenumber> use for conditional format.
View 34 Replies
View Related
Jun 17, 2010
i want to replace 4 digit number in a given string with the same number incremented by 10000.
That mean in the given sting 1201 should be replace by 11201 (Icremented BY 10000).
Input String:
<query><matchAll>true</matchAll><row><columnId>1201</columnId><dataType>31</dataType><op>Like</op><val>North America - Houston</val></row><row><columnId>1212</columnId><dataType>31</dataType><op>!=</op><val>Agreement Date Mismatch</val></row><row><columnId>1212</columnId><dataType>31</dataType><op>!=</op><val>Facility Type Mismatch</val></row><row><columnId>1224</columnId><dataType>31</dataType><op>Like</op><val>y</val></row></query>
Required output :
<query><matchAll>true</matchAll><row><columnId>11201</columnId><dataType>31</dataType><op>Like</op><val>North America - Houston</val></row><row><columnId>11212</columnId><dataType>31</dataType><op>!=</op><val>Agreement Date Mismatch</val></row><row><columnId>11212</columnId><dataType>31</dataType><op>!=</op><val>Facility Type Mismatch</val></row><row><columnId>11224</columnId><dataType>31</dataType><op>Like</op><val>y</val></row></query>
View 7 Replies
View Related
Oct 21, 2011
I have a text field and if the text field has 5 consecutive numbers then I have to extract the number and the previous character from where the 5digit number starting
For example i/p asdfasfsdS251432dasdasd o/p should be S251432
View 10 Replies
View Related
Oct 3, 2013
I gone through many forums and found that the number of voting disks should be always in odd number. Then why the maximum number of voting disk is 32?
View 1 Replies
View Related
May 21, 2010
how do I count a list of number value eg 1,1,1,1,3,3,6,4 and find the one with maximum number which is 1
View 5 Replies
View Related
Mar 9, 2011
I have the following select query that works perfectly fine. Returns 25 rows based on the descending order of the price.But, I want add one more expression to this list of columns in this query (apart from customer_id).
the expression should look like Cust-01 for the first customer from the below query all the way to Cust-25 for the last customer.But how can I can generate 01 to 25 in oracle?
select customer_id from
(select customer_id from capitalPLAN
where member_status = 'MEMBER' AND customer_id NOT in ('156','201','1385','2125','3906','165')
order by price desc
)
where rownum <= 25
View 4 Replies
View Related
Sep 28, 2012
my column type is NUMBER(10,0) ,it accept the input value from text field I using TO_NUMBER(?) to insert value into table, is the a way to handle if the input is 'aaaaaaaaaa' not digit?
View 6 Replies
View Related
Feb 19, 2011
Here is script of tables
Quote:drop table p;
create table p (qty number(3), beg_no number(5));
insert into p values(5, 110);
insert into p values(8, 786);
drop table s;
create table s (used_no number(5));
insert into s values(111);
insert into s values(113);
insert into s values(791);
Table p: it has ticket quantity and ticket begining number. Thus according to first record ticket number will begin at 110 and will end at 110+5 (Beg_no +qty). According to second record ticket number will begin at 786 and will end at 786+8 (Beg_no +qty). This table can have many records.
Table s: it has ticket numbers which are sold. The ticket will always be any number from table and will lay in any record in this format between beg_no and beg_no+qty
Required: I want "p MINUS s" information. i.e.
Quote:
110
112
114
786
787
788
789
790
792
793
I am not expert in level by command.
Oracle version: 9
OS: Windows XP
View 3 Replies
View Related
Feb 19, 2013
I have a report created in Reports6i. I have two fields at the bottom
1.Page Total
2.Voucher Total
I do not want to print the Page Total if the total number of pages = 1.
How can I achieve this?
View 1 Replies
View Related
Apr 19, 2010
i have field(column name ) amata type is number . in excel i am having "," in amount field eg 9,999. how to do it
View 6 Replies
View Related
Mar 12, 2013
I have following table.
CREATE TABLE ABC
(
DPT_NUM NUMBER,
LOT_NUM NUMBER,
ASSOCIATED_WITH_LOT NUMBER
);
SET DEFINE OFF;
Insert into ABC
[code]......
Now i run follwoing query and result is
select * from abc
DPT_NUMLOT_NUMASSOCIATED_WITH_LOT
1501
1502501
1509501
1511
1503
1516
1522
1565
1569565
2601
2602
2604602
2607
2508
I need following result
DPT_NUMLOT_NUMASSOCIATED_WITH_LOT Serial_Number
1501 1
1502501 2
1509501 2
1511 3
1503 4
1516 1
1522 2
1565 3
1569565 3
2601 1
2602 2
2604602 2
2607 3
2508 3
Note that serial number must reset after each 4 lot_num againt dpt_num. Not that where lot is associated in associated_with_lot there serial number must be same as serial number is for associated lot.
View 7 Replies
View Related
Sep 27, 2013
can we convert RAW to number in sql.because i have to bitand of one raw and number variable.
View 3 Replies
View Related
Mar 1, 2013
I have Follwoing Table and data.
CREATE TABLE ABC(DPT_NUM NUMBER,LOT_NUM NUMBER);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 501, 1);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 502, 2);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 509, 3);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 511, 4);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 503, 5);
[Code]...
I write Following query.
SELECT DPT_NUM,LOT_NUM,ROW_NUMBER() OVER(PARTITION BY DPT_NUM ORDER BY DPT_NUM) SRL_NUM FROM ABC;
Result is
DPT_NUMLOT_NUMSRL_NUM
15011
15022
15093
15114
15035
15166
15227
15698
[Code]...
But i want to reset rownum after each 4. Mean after serial number 4 , serail number must start from 1. I want to reset serial number after each 4 records (lot_num) against dpt_num;
View 7 Replies
View Related
Jan 4, 2013
I have a table datatype number (12,10) that I am reading out of. I am taking the value from this source table and inserting it into a destination table of datatype number (12,15).
I do not have the ability to alter the tables. How can i convert this number so i can insert. I am currently getting the error "ORA-01438: value larger than specified precision allowed for this column"
I am trying to use the to_number, but it not working. How can i format this number field so i can read it from source where i have number (12,10) and insert it successfully in a higher precision table of number(12,15)
View 1 Replies
View Related
Oct 29, 2010
I'm trying to find a way to see if a value occurs more than once in a string. I just need to know "T/F", or "Y/N", etc.
The string will be comma delimited.
String: '1,2,3,1'
Ans: "T"
String: '1,2,3,4'
Ans: "N"
They do need to match exactly. for instance
String: '1,2,3,1a'
Ans: "N"
Using some code I found on this site, I coded this but I'm sure there's a better way. Is there??
--Check for Duplicate combination row values
BEGIN
--Query will split the string into individual pieces.
--Group the pieces to see if any 2 rows are the same
--If no rows are the same then "no_data_found" exception is thrown
SELECT 'T'
INTO vResult
[Code]...
View 10 Replies
View Related
Jun 4, 2012
i want to know the all scn number's that are generated yesterday or in any previous day? how can i achieve it?
View 5 Replies
View Related
Jun 14, 2013
would need to convert a number in this way:10.1 ---> 10101.90 ----> 190 How can i?
View 1 Replies
View Related