How can I write the SQL for this result?
Hello my dear,Here first of all the script.
CREATE TABLE ACC_TEST(
AD_ID NUMBER,
AD_NAME VARCHAR2(50),
AD_SPM_ID NUMBER);
/
the data areInsert 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 passing a value of Ad_Id. For example I go to 142 then result must beSelect 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 10 G XEAny help will be useful
Hello
HamidHelal wrote:
WoW! You are totally my point. How do you understand that? l
Guess luck. Guessing is generally not the best way to solve problems. It is generally faster and more reliable to say exactly what you want, as well as give an example.
fallen little more that I want to know, if I want to restrict the output not more then 2, which would be sql?
Now, you're not even giving for 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 just the mother and grandmother of the given line.
I work with the developer of forms a lot. Knowledge of SQL is like sql oracle (9i cerfitication) book. But this type of sql is not available here.
where can I learn this type of sql? SQL different then regular?
Certification is another matter entirely.
There are books and web sites dealing with more advanced techniques. Sorry, I don't know any good enough to recommend. Some authors (such as Tom Kyte) are always good.
Here are a few sites that explain CONNECT BY queries:
http://www.adp-GmbH.ch/ora/SQL/connect_by.html
http://www.oradev.com/connect_by.jsp
Tags: Database
Similar Questions
-
How can I write the trigger for the global temporary Table
Hi Grus,
How can I write the trigger for the global temporary Table.
I created the TWG with trigger using the script below.
CREATE A GLOBAL_TEMP GLOBAL TEMPORARY TABLE
(
EMP_C_NAME VARCHAR2 (20 BYTE)
)
ON COMMIT PRESERVE ROWS;
CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
BEFORE DELETE, UPDATE OR INSERT
ON GLOBAL_TEMP
REFERRING AGAIN AS NINE OLD AND OLD
FOR EACH LINE
BEGIN
INSERT INTO VALUES EMPNAME (: OLD.) EMP_C_NAME);
END;
/
trigger was created successfully, but her would not insert EMPNAME Table...
Please guide if mistaken or not? If not wanting to give a correct syntax with example
Thanks in advance,
Arun M MBEGIN INSERT INTO EMPNAME VALUES (:OLD.EMP_C_NAME); END;
you are referencing old value in insert stmt. BEGIN INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME); END;
then run your app, it works very well...
CREATE GLOBAL TEMPORARY TABLE GLOBAL_TEMP ( EMP_C_NAME VARCHAR2(20 BYTE) ) ON COMMIT PRESERVE ROWS; CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP BEFORE DELETE OR UPDATE OR INSERT ON GLOBAL_TEMP REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN dbms_output.put_line(:OLD.EMP_C_NAME||'yahoo'); INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME); dbms_output.put_line(:OLD.EMP_C_NAME); END; / create table EMPNAME as select * from GLOBAL_TEMP where 1=2 insert into GLOBAL_TEMP values('fgfdgd'); commit; select * from GLOBAL_TEMP; select * from EMPNAME; output: 1 rows inserted commit succeeded. EMP_C_NAME -------------------- fgfdgd 1 rows selected EMP_C_NAME -------------------- fgfdgd 1 rows selected
He got Arun
Published by: OraclePLSQL on December 28, 2010 18:07
-
How can I write the SQL query for this requirement?
Hello
I have a table that looks like this:
NAME | ANNUAL | VALUE
==== | ====== | =====
execno | 480. 000004
step | 480. 0400
SCNA | 480. cd_demo
System | 480. D47-010
type | 480. step
free_text | 480. stage 400
rbare | 480. RBA-1
execno | 482. 000004
SCNA | 482. cd_demo
System | 482. D47-010
free_text | 482. step 300
step | 482. 0300
type | 482. step
rbare | 482. RBA-1
execno | 483. 000001
type | 483. step
rbare | 483. rke1
SCNA | 483. rke10
step | 483. 0240
Now, say that I want to fetch ONLY annual with execno = '000004' and '400' = step and scna = "cd_demo" and system = "d47-010' and type = 'step', how to write SQL code?
At first, it seemed like a simple writing query but I've been struggling with it for hours without success. I must admit though that I'm not strong in SQL :-)
There, can anyone help? Please...
Thanks in advance.
Emmanuel
Published by: user12138559 on October 30, 2009 03:05Hi, Emmanuel.
Welcome to the forum!
Here's a way to do what you asked:
SELECT doc_id FROM table_x GROUP BY doc_id HAVING SUM (CASE WHEN name = 'execno' AND value = '000004' THEN 1 END) > 0 AND SUM (CASE WHEN name = 'step' AND value = '400' THEN 1 END) > 0 AND SUM (CASE WHEN name = 'scna' AND value = 'cd_demo' THEN 1 END) > 0 AND SUM (CASE WHEN name = 'system' AND value = 'd47-010' THEN 1 END) > 0 AND SUM (CASE WHEN name = 'type' AND value = 'step' THEN 1 END) > 0 ;
If you think that a WHERE clause would be used, but WHERE does apply to a single line. You need a condition that checks several rows in the same group.
WHEN has an effect something like WHERE.Published by: Frank Kulash, October 30, 2009 06:26
This solution assumes that (name, annual) is unique.
-
someone stole my computer. How can I disable the program on this computer... or stop the license for this computer/serialnr. ?
Hello
to my knowledge which is one of the benefits of the creative Cloud: just change the password and after a month, the thief can no longer work with her, maybe you can leave same block by Adobe customer service.
And please see Deaktivierung auf einem PC auf den man keinen Zugriff mehr Hat > answer is written in English
If necessary and for any other question, click on through http://helpx.adobe.com/contact.html and 'open' Please use the cat, I for my part had the best experiences. An employee of Adobe Preran I quote: the chat button is enabled as soon as there is an available agent to help.
Hans-Günter
-
How can I write the value of floats Unitronics vision230 PLC with modbus Ethernet
How can I write the value of type Float in unitronics PLC Vision230 modbus ethernet (Ethernet Master Query.vi MB) usinsg I read and write register 32 bits, for example, I want to write the value 23.45 2nd Add. MF. And registry MF is the 32-bit registry. I read and write register 32-bit.
Narendra.
Narendra,
Two characters can type cast into a uint16 you VI supports.
To summarize. Take one (4 bytes). Flatten it to a string (4-byte) divided this string into two parts of 2 bytes each. Cast in u16 (16 x 2 = 32-bit).
However, if you really want to follow the IEEE standards then you will need refer this KB. His is not that simple, but seems closer to what you are looking for.
Amit
-
I bought the live app pga golf, but it doesn't work in my country! How can I cancel the payment for the next month?
There are instructions on this page to manage and stop automatic renewal of subscriptions: view, change or cancel your subscription - Apple Support
-
How can I check the disc for physical integrity on Satellite P305?
I have P305-S8838.
I had some freezing problems earlier this month, and on the notice here, I nu start-up and reduced services a little at a time.
Now, I have a few more crash but don't know if it's a physical disk problem.For example... I have run CHKDSK and does many things and happens at the exact same spot and hangs at step 4 file 5 3498 or 421168 processed.
I tried to run CHKDSK in SafeMode but tells me drive is locked and it will run when I restart. But the restart put back me in normal mode and get the same hang.
Now, for more suspicion of a physical problem. I tried to make a disk image with ACronis and same problem occurs because he says impossible to reading data 226 964, 072 sector and ask if I want to ignore and continue. I say yes to everything. Log shows he made about three of these attempts and crashes.
I ran sfc/scannow and it says found problems that he was unable to fix. The newspaper isn't so long and complex course that all means. I could send these log files if someone can help me understand.
I ran the test of memory OK.
I if I could put in DVD Toshiba and certain diagnoses, but when I put in the disk I get this big warning I'll crush, etc and I have chicken.
This didn't stop me to use the computer, but its all irritating.
How can I check the disc for physical integrity?
Bob
Hello
He idea goo to check the HARD disk and run some diagnostic procedures.
For this, I recommend the freeware tool called Drive Fitness Test.
It allows you to check the HARD disk for certain physical defects.Google for this tool. You can get it from multiple pages download
-
How can I activate the report for individule family members?
How can I activate the report for individule family members?
Hello Dan,.
Activation of activity reports to the members of the family security is easier than the steps below.
To activate the activity tracking
1. on any computer, sign in to the Family Safety website with your Windows Live ID.
2. on the family summary page, click view activity report next to the name of the child, you can turn on activity reports.
3. Select turn on activity monitoring.
4. click on Save.
To learn more, follow this article to the solution and go to the section find out what your kids have been up to on their computer .
Protect your kids with parental controls
Note: Whenever changes are on our parental control settings, we need to update it so that the changes take effect. Click on the button Refresh (located on the left side of the ?) top right of parental control window (the client installed on your computer) to refresh and get the last parameters.
Thank you and best regards.
-
How can I change the time for windows live?
How can I change the time for windows live?
This is the message I get. I need to change to continue working with this program.
Hi stevenwiley,
1. when exactly you get this message?
2 are you facing any problem with Windows Live?
If this happens only with a Windows Live program, you can post your request in the Windows Live forum for assistance.
Check the link for Windows Live support:
Hope this information is useful.
-
Computer XP does not start all of a sudden.
My computer is a HP Lap Top Model zd8000 bought in 2006. Never had a problem with it before.
Drive hard Self Test error #1-07 Fail.
How can I find the meaning of this disc hard test error message?
Thank you
I tried the suggestion using chkdsk/r
The computer ran for a long time, but the computer worked once the process is complete.
First thing I did was back up my data, I was real worried.
Thank you very much!!!
-
How can I get the driver for a Dell Latitude D800 XP wireless?
I have a Dell Latitude D800 that I just did a clean install of XP SP3 to and the Wireless does not work. How can I get the driver for the card wireless to the computer?
Download drivers
Visit the manufacturer's Web site and select your model (this is usually done in the Support section). You should be able to download drivers for your model if they have drivers for your version of Windows. Download the driver and then follow the instructions to install.
Reference Dell Driver Downloads:
-
How can I get the rest of this virus off the coast? Ive found a bunch and them came down until I can get online but I can 't get to work stations or other programs. I have to run in safe mode to do anything properly. This is where I removed the malware and other viruses but I'm not sure it fixed stuff I need in normal mode.
How can I get the rest of this virus off the coast? Ive found a bunch and them came down until I can get online but I can 't get to work stations or other programs. I have to run in safe mode to do anything properly. This is where I removed the malware and other viruses but I'm not sure it fixed stuff I need in normal mode.
Just to add to the answer above, once you have completed the scan with Malwarebytes in SafeMode with network, restart the computer in normal mode, look for the Malwarebytes updates, then perform another analysis.
-
How can I get the Basic for Windows Media Player codec pack?
original title: green screen recently started in windows media player for Vista 64-bit.
It works very well for some videos (like those recorded uncompressed, or some codecs) but a single codec that I save it as coming out of Sony Vegas (Windows Media video V11) goes green screen with playback of the sound. How can I get the basic for 64-bit Windows Media Player codec pack? It worked perfectly for several years now on this machine. Suddenly, it does not work. Last time that I used it very well if a few months ago.
Hi, MisterMark67,
What changes have been made recently to the computer?
Have you tried a system restore to a time before this problem?
Here are answers to some common questions about codecs.
http://Windows.Microsoft.com/en-us/Windows-Vista/codecs-frequently-asked-questions
Windows Vista Codecs Pack base 10.04 (32-bit & 64-bit codecs)
-
How can I disable the narrator for GOOD?
How can I disable the narrator for GOOD! Whenever I turn off the narrator in his small window, (the program access programs) everytiime I turm back on my computer, he returned and annoyingly turns back on and it's a real struggle to find where the Narrator function to turn it off. She sometimes, most of the time I need still to do. Please tell me what to do and how I can stop this ONCE and FOR ALL! without going back over and over every time I turn on my computer. It's very annoying and time consuming. Thank you.
Separated from the:
How can I disable the narrator for GOOD! Whenever I turn off the narrator in his small window, (the program access programs) everytiime I turm back on my computer, he returned and annoyingly turns back on and it's a real struggle to find where the Narrator function to turn it off. She sometimes, most of the time I need still to do. Please tell me what to do and how I can stop this ONCE and FOR ALL! without going back over and over every time I turn on my computer. It's very annoying and time consuming. Thank you.
Separated from the:
This link you has the answer.
If you want another version of the answer, here's the tutorial to show you how enable or DISABLE Narrator
http://www.Vistax64.com/tutorials/124575-Narrator-turn-off.html
-
How can I write a sql with a Union.
How can I write a sql with a Union.
Select emp_name, emp_no, emp_sal of the emp
If show_Less_100000 = "Yes" then emp_sal < 100000 (all values less than 100000)
otherwise the full list.
Thank you
Harsha
Published by: taty on July 31, 2012 11:28SQL> variable show_Less_100000 varchar2(3) SQL> exec :show_Less_100000 := 'Yes'; PL/SQL procedure successfully completed. SQL> select ename, 2 empno, 3 sal 4 from emp 5 where ( 6 :show_Less_100000 = 'Yes' 7 and 8 sal < 2000 9 ) 10 or nvl(:show_Less_100000,'No') != 'Yes' 11 / ENAME EMPNO SAL ---------- ---------- ---------- SMITH 7369 800 ALLEN 7499 1600 WARD 7521 1250 MARTIN 7654 1250 TURNER 7844 1500 ADAMS 7876 1100 JAMES 7900 950 MILLER 7934 1300 8 rows selected. SQL> exec :show_Less_100000 := 'All'; PL/SQL procedure successfully completed. SQL> select ename, 2 empno, 3 sal 4 from emp 5 where ( 6 :show_Less_100000 = 'Yes' 7 and 8 sal < 3000 9 ) 10 or nvl(:show_Less_100000,'No') != 'Yes' 11 / ENAME EMPNO SAL ---------- ---------- ---------- SMITH 7369 800 ALLEN 7499 1600 WARD 7521 1250 JONES 7566 2975 MARTIN 7654 1250 BLAKE 7698 2850 CLARK 7782 2450 SCOTT 7788 3000 KING 7839 5000 TURNER 7844 1500 ADAMS 7876 1100 ENAME EMPNO SAL ---------- ---------- ---------- JAMES 7900 950 FORD 7902 3000 MILLER 7934 1300 14 rows selected. SQL>
SY.
Maybe you are looking for
-
Evil of the formats of date and currency in the Sierra
I'm on MacOS in English, but I want the region settings to reflect the country I live in. After the passage of El Capitan in Sierra, date and currency formats broke. For example, if you set the region of Finland, the date format should be 26.9.2016 i
-
How to change shortcuts on a mac?
How to change shortcuts on a mac? As the order is spotlight, is it possible to change this?
-
I want to use a Blu Ray player in my Mac Pro
I installed a Blu Ray player in my Mac Pro. He worked at one time, but now does not work. I removed the drive bays and reinstall the connector. Now the original superdrive is recognized. The Blu Ray player is not.
-
Pavilion 6620f: upgrade of power
I need a 400W power supply upgrade. What is a compatible PS?
-
Satellite C850D 11(f) does not illuminate
Hey there all, I recently received a defective C850D Satellite of a friend hoping that I could work my magic, basically, the laptop fuel not on. I tried 3 Chargers, I ve stripped to the bare bones unit and run a multimeter on the Board, there is powe