How to write query for below requirement
Hi sir,
i have a table x have one column y which containing value like below
Y
a
b
c
d
I want out put like below kindly help me:
Y
a
d
c
b
Hi ,
Please check:
select y from (
select case when y='a' then 1 else 2 end no, y from table_x
) order by no asc, y desc
with table_x as(
select 'a' y
from dual
union
select 'b' y
from dual
union
select 'c' y
from dual
union
select 'd' y
from dual
select y from (
select case when y='a' then 1 else 2 end no, y from table_x
) order by no asc, y desc
Thank you
Similar Messages
-
How to write query for this in TopLink ?
I am doing a simple search in jsp where the search will the based on the choices chosen by user.
I had given 3 check boxes for those choices.
The problem is, query will be based on the choice or choices chosed by the user.
How to write query for this in TopLink ?
Thanks in Advance..
JayaganeshTry below solution, it is NOT best solution but might work:
Declare @Questions TABLE (QuestionID INT, QuestionText Varchar(100))
INSERT INTO @Questions
VALUES (1, 'Comment'), (2, 'Score')
DECLARE @Answers TABLE (authkey INT, QuestionID INT, questiontext VARCHAR(100), answertext VARCHAR(100))
INSERT INTO @Answers
VALUES (101, 1, 'comment', 'hi!!'), (101, 2, 'score', '4'), (102, 1, 'comment', 'excellent'), (102, 2, 'score', '5'), (103, 2, 'score', '6'), (104, 2, 'score', '8')
SELECT
A.AuthKey
,Q.QuestionID
,Q.QuestionText
,A.AnswerText
FROM
@Questions Q
INNER JOIN @Answers A ON Q.QuestionID = A.QuestionID
UNION
SELECT
A.AuthKey
,Q.QuestionID
,Q.QuestionText
,Null
FROM
@Questions Q
CROSS JOIN @Answers A
WHERE
NOT EXISTS (SELECT 1 FROM @Answers SubQry WHERE SubQry.AuthKey = A.AuthKey AND SubQry.QuestionID = Q.QuestionID)
Output
AuthKey | QuestionID
| QuestionText
| AnswerText
101 | 1 | Comment | hi!!
101 | 2 | Score | 4
102 | 1 | Comment | excellent
102 | 2 | Score | 5
103 | 1 | Comment | NULL
103 | 2 | Score | 6
104 | 1 | Comment | NULL
104 | 2 | Score | 8
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered. -
How to write query for shuttle box
hi
i am creating an shuttle box on my input page and need to write a query to display the selected columns in the shuttle box..
i have created the shuttle bottle and gave the static values in it , i can view my values but cannot understand how to give the condition which allows me to display the data
only for selected columns ...
Please Helpthank you for reply..
I am completely new to oracle apex...i think here there is a prcodure to get default values into the right side box, my question is , how do i write a query for all the items in the left side box columns when selected to right side, the data has to be displayed only for those columns...
i am looking for syntax of the query ...
For eg there 4 columns on the left hand side of the shuttle box
job_id
cluster_id
cluster_code
cluster_name
and i select just job_id and cluster_id to right hand side , i need to display data associated with only these 2 columns...
Please Help
Edited by: user12855387 on Apr 20, 2010 11:08 AM -
How to write select query for below requirement
Hi sir,
i have a table x have one column y which containing value like below
Y
a
b
c
d
I want out put like below kindly help me:
Y
a
d
c
bHi ,
Please check:
select y from (
select case when y='a' then 1 else 2 end no, y from table_x
) order by no asc, y desc
with table_x as(
select 'a' y
from dual
union
select 'b' y
from dual
union
select 'c' y
from dual
union
select 'd' y
from dual
select y from (
select case when y='a' then 1 else 2 end no, y from table_x
) order by no asc, y desc
Thank you -
How to write query for this scenario
Hi -
I have two table like this:
Question:
questionid questiontext
1 comment
2 score
Answer:
authkey questionid
questiontext answertext
101 1 comment hi!!
101 2 score 4
102 1 comment excellent
102 2 score 5
103 2 score 6
104 2 score 8
Here there are two question (score and comment) and answer is stored in answer table. there are case when there is no comment and only answer. but answer would always be there in answer table for each authkey.
I want to write the query that gives the result that if no comment is given for authkey then return null as answer. something like below:
Desired Result:
authkey questionid questiontext
answertext
101 1 comment hi!!
101 2 score 4
102 1 comment excellent
102 2 score 5
103 2 score 6
103 1 comment null
104 2 score 8
104 1 comment null
what query can i write to get the above desired result.
Thanks in advanceTry below solution, it is NOT best solution but might work:
Declare @Questions TABLE (QuestionID INT, QuestionText Varchar(100))
INSERT INTO @Questions
VALUES (1, 'Comment'), (2, 'Score')
DECLARE @Answers TABLE (authkey INT, QuestionID INT, questiontext VARCHAR(100), answertext VARCHAR(100))
INSERT INTO @Answers
VALUES (101, 1, 'comment', 'hi!!'), (101, 2, 'score', '4'), (102, 1, 'comment', 'excellent'), (102, 2, 'score', '5'), (103, 2, 'score', '6'), (104, 2, 'score', '8')
SELECT
A.AuthKey
,Q.QuestionID
,Q.QuestionText
,A.AnswerText
FROM
@Questions Q
INNER JOIN @Answers A ON Q.QuestionID = A.QuestionID
UNION
SELECT
A.AuthKey
,Q.QuestionID
,Q.QuestionText
,Null
FROM
@Questions Q
CROSS JOIN @Answers A
WHERE
NOT EXISTS (SELECT 1 FROM @Answers SubQry WHERE SubQry.AuthKey = A.AuthKey AND SubQry.QuestionID = Q.QuestionID)
Output
AuthKey | QuestionID
| QuestionText
| AnswerText
101 | 1 | Comment | hi!!
101 | 2 | Score | 4
102 | 1 | Comment | excellent
102 | 2 | Score | 5
103 | 1 | Comment | NULL
103 | 2 | Score | 6
104 | 1 | Comment | NULL
104 | 2 | Score | 8
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered. -
How to write query for this?
Hello ppl!
See, I am making a search application. I have a text field and a button on my screen. Now suppose i want to search for "abc", the search is succesful, but when i search for "a*", no results are shown.
So what should be query which will satify both the scenarios?you asking about wild card search in SELECT statements?
The following is the help on wild card search in SELECT statements
... WHERE CITY LIKE '%town%'.
This condition is true if the column CITY contains a string containing the pattern town.
... WHERE NAME NOT LIKE '_n%'.
This condition is true if the column NAME contains a value whose second character is not n.
<b>... WHERE FUNCNAME LIKE 'EDIT#_%' ESCAPE '#'.
This condition is true if the contents of the column FUNCNAME begin with EDIT_.</b> -
Need query for below requirement
create table nsk_temp2 (num number,parent_num number,src_num number);
insert into nsk_temp2 values (1000,null,null);
insert into nsk_temp2 values (1001,1000,null);
insert into nsk_temp2 values (1002,1000,null);
insert into nsk_temp2 values (1010,null,1000);
insert into nsk_temp2 values (2001,1010,null);
insert into nsk_temp2 values (2002,1010,null);
num parent_num src_num
1000
1001 1000
1002 1000
1010 1000
2001 1010
2002 1010
Expected output
num parent_num src_num
1000
1001 1000
1002 1000
1010 1000
2001 1010 1001
2002 1010 1002
2001 -> parent is 1010 and 1010 src_num is 1000 and 1000 is parent for 1001 and 1002, so 1001 and 2001 are identical recordsHi,
This does what you requested:
WITH got_r_num AS
SELECT num, parent_num, src_num
, ROW_NUMBER () OVER ( PARTITION BY parent_num
ORDER BY num
) AS r_num
FROM nsk_temp2
SELECT d.num, d.parent_num
, NVL ( d.src_num
, s.num
) AS src_num
FROM got_r_num d
LEFT OUTER JOIN got_r_num m ON m.num = d.parent_num
LEFT OUTER JOIN got_r_num s ON s.parent_num = m.src_num
AND s.r_num = d.r_num
ORDER BY d.num
;Whether or not it gets the right results for the right reasons, I can't say, since I know so little about the reasons.
If 1001 and 2001 are identical, aren 1001 and 2002 identical, too? Can the parent_num/num hierarchy extend beyond 2 levels? What would happen if 1000 had more, or fewer, children than 2000? -
How to write query for this given information???
I have table (employees) like this
Hire_date
Salary
04-jan-1991
2000
05-mar-1991
1300
12-sep-1991
2400
19-feb-1992
3000
17-apr-1992
1000
23-nov-1992
1200
25-jan-1993
1000
06-jun-1993
1200
I want to get output like this
Hire_date
Salary
Years in range
total
04-jan-1991
2000
05-mar-1991
1300
12-sep-1991
2400
01-jan-1991 to 31-dec-1991
5700
19-feb-1992
3000
17-apr-1992
1000
23-nov-1992
1200
01-jan-1992 to 31-dec-1992
4200
25-jan-1993
1000
06-jan-1993
1200
01-jan-1993 to 31-dec-1993
2200
give me some ideas guysWithout using analytic functions,
select
hire_date,salary,
decode(hire_date,null,extract(year from hire_date)) year_tag,
decode(hire_date,null,sum(salary)) total_sal
from
employees
group by grouping sets ((hire_date,salary,extract(year from hire_date)),extract(year from hire_date),())
Output
HIRE_DATE SALARY YEAR_TAG TOTAL_SAL
04-JAN-91 2000
05-MAR-91 1300
12-SEP-91 2400
1991 5700
19-FEB-92 3000
17-APR-92 1000
23-NOV-92 1200
1992 5200
25-JAN-93 1000
06-JUN-93 1200
1993 2200
13100 -
How to write sql query for below mentioned eaxmple.
Hi,
I have requirement.
There are number of rows and I need the result through query as follows.Please help me to proved sql query for below mentioned requirement.
example: table TEST.
COLA COLB COLC COLD COLE COLF MANAGER 5 NULL NULL 3 NULL
SR.MANAGER 6 3 NULL NULL NULL
VP 5 5 4 5 5
I have to write the sql query if COLA IS MANAGER THEN CONSIDER MANGER RECORD,AND IF ANY COLUMN FILED IS NULL FOR MANGER THEN CONSIDER COLA IS SR.MANGER, AND IF ANY COLUMN FILED IS NULL FOR SR,MANGER THEN CONSIDER VP records.
I need output as below.
COLB COLC COLD COLE COLF
5(manager) 3(sr.manger) 4(vp) 3(manger) 3(vp)
Please provide the for above mentioned output.
ThanksDuplicate thread. please view the answer posted in your first thread.
how to write sql query.
And, please don't post any duplicate thread.
Regards.
Satyaki De. -
How to write sql query for below example.
Hi,
I have requirement.
There are number of rows and I need the result through query as follows.Please help me to proved sql query for below mentioned requirement.
example: table TEST.
COLA COLB COLC COLD
MANAGER 5 NULL null
SR.MANAGE 6 3 NULL
VP 5 5 4
I have to write the sql query if COLA IS MANAGER THEN CONSIDER MANGER RECORD,AND IF ANY COLUMN FILED IS NULL FOR MANGER THEN CONSIDER COLA IS SR.MANGER, AND IF ANY COLUMN FILED IS NULL FOR SR,MANGER THEN CONSIDER VP records.
I need output as below.
COLB COLC COLD
5(MANGER) 3(sr.manger) 5(vp)
Please provide the for above mentioned output.
Thanks<<if COLA IS MANAGER THEN CONSIDER MANGER RECORD>>
What does this sentence means? COLA does not cnatin a single record but the number of records with diffrent values.
Regards
Arun -
Can we write query for fomatted search without from clause
can we write query for fomatted search without from clause as below.
SELECT (($(u_amt)*14)/100)
here U_amt is a UDF .I want to assign this to another field .
Rgds,
RajeevHi Rajeev,
You can write query for FMS without from. That is because you can omit it when you get value from active form by default. The grammar of it is:
Select $[$38.u_amt.0\] * 14/100 in your case if you have item type marketing document @line level.
From View-System Information, you can get the info you need for your FMS query at the left bottom of your screen.
Thanks,
Gordon -
Does anybody know how to write GUI for J2ME?
Does anybody know how to write GUI for J2ME?
Thanks!Hi..! I don't know exactly... it's a good question. I refered something. U visit below URL's.
http://www.java-pro.com/upload/free/features/javapro/2000/13iss00/rg0013/rg0013.asp
http://developer.java.sun.com/developer/technicalArticles/wireless/midpui/ -
How to write code for page up and page down buttons on alv screen?
Hi,
Page up and page down buttons are not working in general alv report. Thease buttons are in disable mode. But is stnd. transactions (tcode : fbl5n) these are enabled and working properly, but we can't debug this with /h
How to write code for page up and page down buttons on alv screen?Poonam,
On doing the screen debugging it took me over to Include LSTXWFCC ,kindly check the below code.
module cc_display.
fcode = sy-ucomm(4).
case sy-ucomm(4).
when 'P--'.
perform cc_firstpage.
when 'P-'.
perform cc_prevpage.
when 'P+'.
perform cc_nextpage.
when 'P++'.
perform cc_lastpage.
when 'EX--'.
perform cc_firstcopy.
when 'EX-'.
perform cc_prevcopy.
when 'EX+'.
perform cc_nextcopy.
when 'EX++'.
perform cc_lastcopy.
I guess it can give you some lead.
K.Kiran. -
How to write program for handling script ?
In script i have 2 pages.
In first page i have constant windows and variable windows.
In second page i have main window.
How to write program for this?Hi
You need to write a driver program. You need to use open form, then write_form to write data into various windows and then close_form to close.
As you don't want main window in the first page first try out just by having the window in the second page; i guess system will take care of it. As all other windows filled and if u start writing data in the main it'll go for next page.
If doesn't work have the window on the first page with the least hight and write a command
IF &SYST-PAGE& EQ 1
NEXT-PAGE.
ENDIF.
Then in the second page you can have the main window hight as per your requirement.
Here is an example
(1) Get customer data
TABLES: scustom, sbook, spfli.
DATA: bookings like sbook...
select * from...
(2) Open form
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DEVICE = 'PRINTER'
FORM = 'S_EXAMPLE_1'
DIALOG = 'X'
EXCEPTIONS
others = 1
(3) Print table heading
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HEADING'
TYPE = 'TOP'
WINDOW = 'MAIN'
FUNCTION = 'SET'
(4) Print customer bookings
LOOP AT bookings WHERE
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'BOOKING'
TYPE = 'BODY'
WINDOW = 'MAIN'
ENDLOOP
(5) Close form
CALL FUNCTION 'CLOSE_FORM'
Regards
Surya. -
HR ABAP How to Write BDC For Infotype 0586
Hi Experts
Can Any One tell me how to write BDC for Infotype 0586 and also 585.
If we enter into the maintaining Screen, the lines in the Screen will dynamically changing depending on the values.
When I am doing recording , If I press page down after entering values in top lines, the lines are changing and the records are not updating Correctly.
I need to write BDC to Create Change.
Can any one please help me in this regard?
Thanks in Advance.
Regards
Avinash.http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.google.co.in/search?hl=en&q=SAPBDCtable+control&meta=
http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.sap-img.com/abap/question-about-bdc-program.htm
Maybe you are looking for
-
Java 7 update 21 breaks all existing JWS desktop shortcuts on windows
I just updated from 1.7u17 to 1.7u21 and all my Java Web Start shortcuts broke because I no longer have C:\Windows\SysWOW64\javaws.exe. I can "reinstall" the web start apps or delete their shortcuts and re-create them and they work because they now p
-
Adobe AIR usage on Devices(other than mobile and TV)
Hi All, Just want to know that is adobe air is being used on other Devices except mobile and TV? For e.g. in any machine of Medical Science or automobile etc.If any one is having any idea then please share. Thanks in Advance. with Regards, Shardul
-
Hi all I downloaded the sample application from sdn called <b>com.sap.netweaver.kmc.globalservice.zip</b>Its sample global service for capturing KM events. I modified only the EventHandler.java and added some JCO statements in the method when somethi
-
A non-numeric character was found ... iAS 8 & ora 8.1.6
I have a problem in iAS 8 and Oracle 8.1.6 under windows 2000. The problem is calling nested packages using plql gateway, I mean I call one package and it call's another package, this operation throws " a non-numeric character was found where a numer
-
AdvancedDataGrid with HTTPService
Hi All, I have problem with AdvancedDataGrid by using HTTPService.Actually i don't know how to get the data from xml file and display in AdvancedDataGrid but i know how to get the data from xml file and display in DataGrid. Here XML file structure is