Home » Developer & Programmer » Forms » fetch the exact values against subjects. (Form 6i , oracle 10g database)
fetch the exact values against subjects. [message #690239] |
Sat, 28 December 2024 22:30 |
shahzad-ul-hasan
Messages: 643 Registered: August 2002
|
Senior Member |
|
|
I have 3-tables. catedet, bkkdet, bredet
-----First STable
CREATE TABLE catedet (
citd number(5) primary key,cdesc varchar2(120),srate number(10,3),ctype varchar2(3));
insert into catedet
values
(1,'ENGLISH NEW SERIES-A',450,'FVU');
insert into catedet
values
(2,'URDU SERIES-A',450,'FVU');
insert into catedet
values
(3,'MATH SERIES-A',450,'FVU');
insert into catedet
values
(5,'ART STUDIO',250,'FVU');
insert into catedet
values
(6,'G.K SERIA-A',340,'FVU');
insert into catedet
values
(7,'ALQURAN NAZARA',130,'FVU');
--New Type
insert into catedet
values
(8,'ENGLISH GOLEN SERIES SNC',490,'TWE');
insert into catedet
values
(9,'URDU GOLEN SERIES SNC',490,'TWE');
insert into catedet
values
(10,'MATH GOLEN SERIES SNC',490,'TWE');
insert into catedet
values
(11,'ART STUDIO SNC',390,'TWE');
insert into catedet
values
(12,'GRAMMAR SERIES SNC',455,'TWE');
insert into catedet
values
(13,'ALQURAN IBTADIA SNC',225,'TWE');
insert into catedet
values
(14,'ISAMAIAE SERIES SNC',435,'TWE');
--New Type
insert into catedet
values
(15,'ENGLISH GOLEN SERIES SNC',390,'THE');
insert into catedet
values
(16,'URDU SERIES SNC',590,'THE');
insert into catedet
values
(17,'MATH OXFORD SNC',490,'THE');
insert into catedet
values
(18,'ART STUDIO SNC',390,'THE');
insert into catedet
values
(19,'GRAMMAR SERIES SNC',565,'THE');
insert into catedet
values
(20,'SCIENCE SNC',490,'THE');
--New Type
insert into catedet
values
(21,'ENGLISH GOLEN SERIES SNC',390,'FRE');
insert into catedet
values
(22,'URDU SERIES SNC',590,'FRE');
insert into catedet
values
(23,'MATH OXFORD SNC',490,'FRE');
insert into catedet
values
(24,'ART STUDIO SNC',390,'FRE');
insert into catedet
values
(25,'SCIENCE SERIES SNC',565,'FRE');
insert into catedet
values
(26,'GRAMMAER SERIES SNC',490,'FRE');
insert into catedet
values
(27,'SCIENCE SERIES SNC',525,'FRE');
---2nd table:
--bOOKS qUANTITY bY tYPE
create table bkkdet (
sno number(6) primary key,ctyp varchar2(3),bamt number(7),b1 number(2),b2 number(2),b3 number(2),b4 number(2),b5 number(2),b6 number(2),
b7 number(2),b8 number(2),b9 number(2),btot number(3));
insert into bkkdet
values
(1,'FVU',2700,1,1,1,1,1,1,1,0,0,7);
insert into bkkdet
values
(2,'TWE',2300,1,1,1,1,1,1,0,0,0,6);
insert into bkkdet
values
(3,'THE',2600,1,1,1,1,1,1,0,0,0,6);
insert into bkkdet
values
(4,'FRE',2800,1,1,1,1,1,1,1,0,0,7);
-- third table
create table bredet (
stuid number(4),btyp varcar2(3),b1 number(2),b2 number(2),b3 number(2),b4 number(2),b5 number(2),b6 number(2),
b7 number(2),b8 number(2),b9 number(2));
i am using form to receive the book detail from 2nd table into 3rd table upon ctyp=btyp. when the ctyp iq equal to btyp then it will post the (b1,b2,b3,b4,...b9) values into third table on (trigger)key next item. when i change the value of b1 from 1 to 0 its value substract from total value and when i put value 1 in b1 its value add in total.
I want to fetch the exact srate when its match the first three character of the subject like (ENG,MAT,ART,GRA ETC). I have tried tofix with rownumber but cannot succeed.
-------for b1
Cursor c1 is select citd, srate,rouwnum
from (
select citd,srate from catedet
where cytpe=:btyp
--and cdesc like 'ENG%'
order by citd)
where rownum=1; --Works Fine
--for b2
Cursor c1 is select citd, srate,rouwnum
from (
select citd,srate from catedet
where cytpe=:btyp
-- and cdesc like 'URDU%'
order by citd)
where rownum=2; --Work Fine
--for b5,b7
Cursor c1 is select citd, srate,rouwnum
from (
select citd,srate from catedet
where cytpe=:btyp
and cdesc like 'GRAM%' or cdesc like 'SCI%'
order by citd); --not fetch the exact srate ????
please help me to solve this problem.
please check the attached file.
-
Attachment: Untitled.jpg
(Size: 56.55KB, Downloaded 31 times)
|
|
|
|
|
Re: fetch the exact values against subjects. [message #690242 is a reply to message #690241] |
Sun, 29 December 2024 23:16 |
shahzad-ul-hasan
Messages: 643 Registered: August 2002
|
Senior Member |
|
|
SELECT citd, srate, rnum
FROM (
SELECT citd, srate, ROWNUM AS rnum
FROM (
SELECT citd, srate
FROM catedet
WHERE cytpe = :btyp
AND (
(cytpe = '1' AND cdesc LIKE 'G.K%') OR
(cytpe = '2' AND (cdesc LIKE 'GRAM%' OR cdesc LIKE 'SCI%')) OR
(cytpe = '3' AND (cdesc LIKE 'GRAM%' OR cdesc LIKE 'SCI%'))
)
ORDER BY citd
)
WHERE ROWNUM <= 2
)
WHERE rnum = 2;
please advise it is correct.
|
|
|
Re: fetch the exact values against subjects. [message #690246 is a reply to message #690242] |
Mon, 06 January 2025 05:48 |
cookiemonster
Messages: 13962 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
That query will given the 2nd row that the inner query returns ordered by citd. Selecting rnum at the top leval seems pointless since it has to be 2.
Whether or not that's actually what you need I've no idea, your requirement is unclear.
|
|
|
Goto Forum:
Current Time: Fri Jan 17 14:23:53 CST 2025
|