How to Write query to order by
if have like this
select empno,ename from employee
order by :choice (i want to select user from list empno or ename for order by)
but it doesnt work
Hi,
you should use "&choice" instead of ":choice".
You must have a placeholder field named "choice" and you must initialize this field with either "empno" or "ename".
Bye
Raffy
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 to list all the employees of deptno 20
Hi ,
I am new to Oracle...Recently I got job.... Could you please help me....
How to write a query for
1) List all the Clerks of Deptno 20 and
2) List the emps along with their exp and whose daily salary is more than 100rsits not wrong that you ask , but this is basic question and my suggestion is to start reading some manual specially since you got job , Read oracle documentation gogole what you want if you didn't find any answer post here and we will help you .
Check this link
http://www.oracle-dba-online.com/sql/oracle_sql_tutorial.htm
http://www.w3schools.com/sql/default.asp
http://www.java2s.com/Tutorial/Oracle/CatalogOracle.htm
And you will find more & more .. create your own vmware oracle provide with learning database called XE (express edition) test it and hope this information is useful for you -
Hi
I have UDF on form. How to make query, to choose values values from OITM in U_MODEL where U_BRAND = definite valueHi,
1.Use same query (as attached in screen shot) and assign to U_model as per attached below.
2. To get list, just Press shift + F2 at U_model
Thanks & Regards,
Nagarajan -
How to write query group by time(minutes)
Hi,
i am writting query like this.
select host_id,pd_user, pdUserUtil,
timestamp from
(select host_id,pd_user,
avg(pd_cpu) pdUserUtil,
to_Char(PD_REPORTED_TIMESTAMP,'yyyy-mm-dd hh:MI') timestamp
from sp_process_detail_current SP
where exists (select * from
sp_process_detail_current
having
max(PD_REPORTED_TIMESTAMP)-sp.PD_REPORTED_TIMESTAMP<5/1440)
group by pd_user,host_Id,to_Char(PD_REPORTED_TIMESTAMP,'yyyy-mm-dd hh:MI'))
where host_id='DSCP04881' and pd_user='TOMCAT'
TIMESTAMP PD_USER
2006-06-30 08:07 TOMCAT
2006-06-30 08:08 TOMCAT
2006-06-30 08:10 TOMCAT
BUT WHILE ACCESSING IN JAVA
java.lang.NumberFormatException: For input string: "30:08:07"
at java.lang.NumberFormatException.forInputString(NumberFormatException.Question: What datatype in Java are you using as placeholder for the timestamp column?
It's only taking the "2006-06-" part.
Post here the java code (an exceprt of course), though I feel there's better forums for this subject. -
Hi,
I need expert advice.
on daily basis we are updating meter reading ( meter reading is nothing but "meter number / unit / date".
Let say there are 10 apartment and each apartment has separate meter.
i need to write query get missing meter reading on a specific date.
ThanksUnit Master
401
402
403
404
Daily Meter Reading
date unit meter
01-01-01 1 401
01-01-01 1 402
01-01-01 1 404 ( on 1st of jan user update the meter reading but if you notice unit number 403 is missing)
02-01-01 1 401
02-01-01 402 ( on 2nd of jan user update the meter reading but if you notice this time 402 is meter unit is missing)
02-01-01 1 403
02-01-01 1 404
03-01-01 401
03-01-01 1 402
03-01-01 1 403 ( on 3rd of jan user update the meter reading but if you notice this time meter unit is missing for 401 and 404 is unit is missing)
We want the following output
if user run report on 1st of jan system should return value of 403 unit number
if user run report on 2nd of jan then system should return value of 402 unit number
if user run report on 3rd of jan then system should return value of 401/404 unit number
Hope this help to get my expected answer. -
QUESTION: HOW TO WRITE QUERY WITH MANY TO MANY RELATIONSHIPS
Could someone help me out here?
I was sitting here looking at some tables ie table_name and synonyms and wondering.
If a table can belong to many synonyms and a synonym can belong to many tables how would one write a query where I would like to know which tables belong to each synonym or on the other hand which synonym belongs to what tables?
Would I try to develop an outside join for this, a corrolated query or a query with a subquery or would there be another format that would work better?
What would be the best method of attack on this?
Thanks for your thoughts on this.
alActually, the relationship is not many to many. A table can have many synonyms, but a synonym within a namespace (i.e. a PUBLIC synonym, or a private synonym created by a user) can only point to one table. The xxx_synonmys tables already contain the information about the table_name and table_owner.
John -
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 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 with low cost
hi
i want to write a query of low cost for the following scenario.
in a table
if a person got a salary >=10000 he is in grade A
if a person got salary >=7000 he is in grade B
if a person got salary >=5000 he is in grade C
if a person got salary >=3000 he is in grade D
else grade E.use CASE
case when salary >= 10000 then 'A'
when salary >= 7000 then 'B'
else 'E'
end as grade
-
HOW TO WRITE QUERY OR PL/SQL PROGRAM FOR THIS
I HAVE TABLE X
SELECT ENO FROM X
ENO
123
423
332
562
678
986
621
WHEN I RUN PL/SQL PROGRAM I WILL PASS PARAMETER
FOR EXAMPLE LIKE 134
I NEED OUTPUT LIKE
134 EXIST OUTPUT
123
423
332
562
621
134 NOT EXIST OUTPUT
678
986
Regards
DevThis?
<tested in TOAD>
SQL> accept my_parm
old: with t as (
select '123' eno from dual union all
select '423' from dual union all
select '332' from dual union all
select '562' from dual union all
select '678' from dual union all
select '986' from dual union all
select '621' from dual )
select eno || ' ' || output_type results
from (
select to_char(&&my_parm) eno, 'EXIST OUTPUT' output_type, 1 output_id
from dual union all
select null eno, null output_type, 3 output_id
from dual union all
select to_char(&&my_parm) eno, 'NOT EXIST OUTPUT' output_type, 4 output_id
from dual union all
select
eno,
null,
case when regexp_instr(eno,'[' || &&my_parm || ']') >0
then 2
else 5
end output_id
from t
order by output_id, eno
new: with t as (
select '123' eno from dual union all
select '423' from dual union all
select '332' from dual union all
select '562' from dual union all
select '678' from dual union all
select '986' from dual union all
select '621' from dual )
select eno || ' ' || output_type results
from (
select to_char(134) eno, 'EXIST OUTPUT' output_type, 1 output_id
from dual union all
select null eno, null output_type, 3 output_id
from dual union all
select to_char(134) eno, 'NOT EXIST OUTPUT' output_type, 4 output_id
from dual union all
select
eno,
null,
case when regexp_instr(eno,'[' || 134 || ']') >0
then 2
else 5
end output_id
from t
order by output_id, eno
SQL> with t as (
select '123' eno from dual union all
select '423' from dual union all
select '332' from dual union all
select '562' from dual union all
select '678' from dual union all
select '986' from dual union all
select '621' from dual )
select eno || ' ' || output_type results
from (
select to_char(134) eno, 'EXIST OUTPUT' output_type, 1 output_id
from dual union all
select null eno, null output_type, 3 output_id
from dual union all
select to_char(134) eno, 'NOT EXIST OUTPUT' output_type, 4 output_id
from dual union all
select
eno,
null,
case when regexp_instr(eno,'[' || 134 || ']') >0
then 2
else 5
end output_id
from t
order by output_id, eno
RESULTS
134 EXIST OUTPUT
123
332
423
621
134 NOT EXIST OUTPUT
562
678
986
10 rows selected.Message was edited by:
MScallion -
How to write query to enlist OAF personalizations done by user
Hi All,
I need query which will tell me what are the OAF personalizations done by user, excluding seeded personalzaition done by Oracle.
--ParagI think someone should look at this, as this will be very useful for all.
--Parag Narkhede -
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
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?
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> -
How to write query to get the following o/p
Hi i've the following data and
create table hirarchical(prnt_id number,child_id number)
insert into hirarchical values(1,2)
insert into hirarchical values(1,3)
insert into hirarchical values(1,4)
insert into hirarchical values(2,5)
insert into hirarchical values(2,6)
insert into hirarchical values(2,7)
insert into hirarchical values(3,8)and
If i give in where condition prnt_id=1 then
the o/p should be 7 instead of 1 as it's having all connected childs...
thanks in advanceuser10502250 wrote:
If my reply is correct or helpful please mark it so.Begging for points is unprofessional and considered poor netiquette. It also makes a mockery of the already poor points system, by putting pressure on the original poster to award points for answers that may or may not be the most helpful or correct. If your answer is correct or helpful and meets the needs of the original poster then it is entirely up to them to award points as they see fit when they feel they have had sufficient answers or responses. Most of the people on the forum who have gained a lot of points have done so through providing good answers and without needing to ask for them. Please avoid such begging in future.
Maybe you are looking for
-
Hundreds of roles for a J2EE application using SSO/OID
We are starting to develope a J2EE software that will have hundreds of logical roles. These logical roles must be assignable to users and groups on OID. When prototyping this scenario, we were not able to make this work well enough. Namely, in OIDDAS
-
How to use Ajax Get Multiple Values in Tabular form?
Hi All- I am trying to use AJAX to get multiple values in tabular form by using Denes Kubicek's example in the following link - http://apex.oracle.com/pls/otn/f?p=31517:239:9172467565606::NO::: Basically, I want to use the drop down list to populate
-
Has anyone had a problem with a late 2009 27 inch iMac display showing vertical lines?
Can only display and work the computer in safe mode. When performing a regular boot, the lines appear at the Apple logo and then the screen goes blank and stays blank. Problem first started couple of weeks ago with the computer/display freezing with
-
I have a client with a large gallery and I am wanting to do pagination with prev next and page numbers. Has anybody seen this using the photo gallery module not just a webapp?
-
Sampling Point / Storage Location in Inspection Lot
Hello, We are looking for sampling point / storage location entry in Quality Certificate while dispatching it to customer, but these two fields are not available in inspection lot. Is there any possibility of making either of these two to enter while