write the query sql for the following situation?
We have a table like format following...A AND B
...................
10 30
50 40
60 80
90 100
so to write the query and get the result like formats following...
RESULT
............
30
50
80
100
Try this... He's one of the interview question. I can't write the query...
If a knowledge write the query...
Hello
Try this
select (case when a>b then a else b end) "Result" from ;
Tags: Database
Similar Questions
-
a disk error has occurred while trying to write the following file
I was working on my video and I put in a video file and a 10 seconds later, I get an error saying "a disk error occurred while trying to write the following file.
and audio of the video was not working I close Premiere Pro and open again to do the same thing and it happens again if you know how to fix this please tell me I need to change my video so I can get it to the top on youtube tomorrow.
I contacted support and it turns off everything, I had to do was move the first clip on the desktop... lol Thanks much for the great help! Sorry for the trouble
-
How to write the following SQL
I have a table with the following columns seq_no, customer_no, sales_person, card_type, NTB_Cust, paid_flag. He basically tells what a person sale that sold the customer what card, and if the customer is a New_To_Bank. Seq_no field is a sequence running. I need fill out the paid_flag as 1 or 0 according to certain rules.
The first point to consider is that the card_type should be "PREFERRED" and NTB_Cust = "NTB".
Then, if the sales_person has sold two cards that follow with the above criteria, in the same customer_no, then only the first will be marked with paid_flag = 1. If he sold 3 consecutive to the same customer cards, then the 1st and the 3rd will be marked as paid_flag = 1. If the sales_person has sold 4 cards to the same customer and then the 1st and the 3rd will be marked as paid_flag = 1. And so on.
See below the expected value of paid_flag
seq_no card_type NTB_Cust paid_flag customer_no sales_person
XXX 999 FAVORITE NTB 1 1
2 999 FAVORITE NTB XXX 0
XXX 3 999 FAVORITE NTB 1
4 999 PRESTIGE NTB XXX 0
XXX 5 888 FAVORITE NTB 1
XXX 6 888 FAVORITE OLD 0
7 FAVORITE NTB 888 XXX 1Hello
Try
WITH T1 AS ( SELECT 1 seq_no, 'XXX' sales_person, 999 customer_no, 'PREFERED' card_type, 'NTB' NTB_Cust, 1 paid_flag FROM DUAL UNION ALL SELECT 2, 'XXX', 999, 'PREFERED', 'NTB', 0 FROM DUAL UNION ALL SELECT 3, 'XXX', 999, 'PREFERED', 'NTB', 1 FROM DUAL UNION ALL SELECT 4, 'XXX', 999, 'PRESTIGE', 'NTB', 0 FROM DUAL UNION ALL SELECT 5, 'XXX', 888, 'PREFERED', 'NTB', 1 FROM DUAL UNION ALL SELECT 6, 'XXX', 888, 'PREFERED', 'OLD', 0 FROM DUAL UNION ALL SELECT 7, 'XXX', 888, 'PREFERED', 'NTB', 1 FROM DUAL ) SELECT T1.*, CASE WHEN MOD(ROW_NUMBER() OVER (PARTITION BY customer_no, card_type ORDER BY SEQ_NO),2)=1 AND CARD_TYPE = 'PREFERED' AND NTB_Cust='NTB' THEN 1 ELSE 0 END PAID_FLG_FROM_SQL FROM T1 ORDER BY SEQ_NO;
* 009 *.
-
Best way to write the following query
Hello
I have following table structures and data...
And I wrote the request in order to obtain records that are superior to BBB-
But could you please me to write in a simpler way.
I used the table rt_srt twise in the above querycreate table obj (ob_id ) as select 1 from dual union all select 2 from dual union all select 3 from dual union all select 4 from dual union all select 5 from dual union all select 6 from dual create table og_dt (or_id , rt_cd,rt_ct_cd) AS SELECT 1 ,'B','BRID' FROM DUAL UNION ALL SELECT 1 ,'B','BRD' FROM DUAL UNION ALL SELECT 2 ,'BB-','ACR' FROM DUAL UNION ALL SELECT 2 ,'BB-','AQCR' FROM DUAL UNION ALL SELECT 3 ,'BBB','QYRE' FROM DUAL UNION ALL SELECT 4 ,'BB+','TUR' FROM DUAL UNION ALL SELECT 5 ,'BBB-','KUYR' FROM DUAL create table rt_srt (srt_ord,rt_cd,rt_ct_cd) as select 50 ,'B','VID' FROM DUAL UNION ALL SELECT 50 ,'B','BRD' FROM DUAL UNION ALL SELECT 40 ,'BB-','ACR' FROM DUAL UNION ALL SELECT 41 ,'BB-','AQCR' FROM DUAL UNION ALL SELECT 30 ,'BBB','QYRE' FROM DUAL UNION ALL SELECT 33 ,'BB+','TUR' FROM DUAL UNION ALL SELECT 20 ,'BBB-','KUYR' FROM DUAL select distinct * from obj,og_dt,rt_srt where obj.ob_id=og_dt.or_id and og_dt.rt_cd = rt_srt.rt_cd and og_dt.rt_ct_cd=rt_srt.rt_ct_cd and rt_srt.srt_ord > all (select rt_srt.srt_ord from rt_srt where rt_cd='BBB-'
Could you advice please write it in simple way.
Thank youHere's the implementation plans for 3 possible solutions (including the one you posted). Solutions of second & third assumes that rt_srt.srt_ord is not null:
SQL> explain plan for 2 select distinct * 3 from obj, 4 og_dt, 5 rt_srt 6 where obj.ob_id = og_dt.or_id 7 and og_dt.rt_cd = rt_srt.rt_cd 8 and og_dt.rt_ct_cd = rt_srt.rt_ct_cd 9 and rt_srt.srt_ord > all ( 10 select rt_srt.srt_ord 11 from rt_srt 12 where rt_cd = 'BBB-' 13 ) 14 / Explained. SQL> @?\rdbms\admin\utlxpls PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- Plan hash value: 3210303028 --------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 7 | 504 | 16 (25)| 00:00:01 | | 1 | HASH UNIQUE | | 7 | 504 | 16 (25)| 00:00:01 | | 2 | MERGE JOIN ANTI NA | | 7 | 504 | 15 (20)| 00:00:01 | | 3 | SORT JOIN | | 7 | 385 | 11 (19)| 00:00:01 | |* 4 | HASH JOIN | | 7 | 385 | 10 (10)| 00:00:01 | |* 5 | HASH JOIN | | 7 | 238 | 7 (15)| 00:00:01 | PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- | 6 | TABLE ACCESS FULL| OBJ | 6 | 78 | 3 (0)| 00:00:01 | | 7 | TABLE ACCESS FULL| OG_DT | 7 | 147 | 3 (0)| 00:00:01 | | 8 | TABLE ACCESS FULL | RT_SRT | 7 | 147 | 3 (0)| 00:00:01 | |* 9 | SORT UNIQUE | | 1 | 17 | 4 (25)| 00:00:01 | |* 10 | TABLE ACCESS FULL | RT_SRT | 1 | 17 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 4 - access("OG_DT"."RT_CD"="RT_SRT"."RT_CD" AND PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- "OG_DT"."RT_CT_CD"="RT_SRT"."RT_CT_CD") 5 - access("OBJ"."OB_ID"="OG_DT"."OR_ID") 9 - access("RT_SRT"."SRT_ORD"<="RT_SRT"."SRT_ORD") filter("RT_SRT"."SRT_ORD"<="RT_SRT"."SRT_ORD") 10 - filter("RT_CD"='BBB-') Note ----- - dynamic sampling used for this statement (level=2) 31 rows selected. SQL> explain plan for 2 select distinct * 3 from obj, 4 og_dt, 5 rt_srt 6 where obj.ob_id = og_dt.or_id 7 and og_dt.rt_cd = rt_srt.rt_cd 8 and og_dt.rt_ct_cd = rt_srt.rt_ct_cd 9 and rt_srt.srt_ord > ( 10 select max(rt_srt.srt_ord) 11 from rt_srt 12 where rt_cd = 'BBB-' 13 ) 14 / Explained. SQL> @?\rdbms\admin\utlxpls PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- Plan hash value: 3391900174 --------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 55 | 14 (15)| 00:00:01 | | 1 | HASH UNIQUE | | 1 | 55 | 14 (15)| 00:00:01 | |* 2 | HASH JOIN | | 1 | 55 | 10 (10)| 00:00:01 | | 3 | MERGE JOIN CARTESIAN| | 2 | 68 | 6 (0)| 00:00:01 | |* 4 | TABLE ACCESS FULL | RT_SRT | 1 | 21 | 3 (0)| 00:00:01 | | 5 | SORT AGGREGATE | | 1 | 17 | | | PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- |* 6 | TABLE ACCESS FULL| RT_SRT | 1 | 17 | 3 (0)| 00:00:01 | | 7 | BUFFER SORT | | 6 | 78 | 3 (0)| 00:00:01 | | 8 | TABLE ACCESS FULL | OBJ | 6 | 78 | 3 (0)| 00:00:01 | | 9 | TABLE ACCESS FULL | OG_DT | 7 | 147 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("OBJ"."OB_ID"="OG_DT"."OR_ID" AND "OG_DT"."RT_CD"="RT_SRT"."RT_CD" AND PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- "OG_DT"."RT_CT_CD"="RT_SRT"."RT_CT_CD") 4 - filter("RT_SRT"."SRT_ORD"> (SELECT MAX("RT_SRT"."SRT_ORD") FROM "RT_SRT" "RT_SRT" WHERE "RT_CD"='BBB-')) 6 - filter("RT_CD"='BBB-') Note ----- - dynamic sampling used for this statement (level=2) 30 rows selected. SQL> explain plan for 2 select distinct obj.*, 3 og_dt.*, 4 rt_srt.srt_ord, 5 rt_srt.rt_cd, 6 rt_srt.rt_ct_cd 7 from obj, 8 og_dt, 9 ( 10 select t.*, 11 max(case rt_cd when 'BBB-' then srt_ord end) over() max_srt_ord 12 from rt_srt t 13 ) rt_srt 14 where obj.ob_id = og_dt.or_id 15 and og_dt.rt_cd = rt_srt.rt_cd 16 and og_dt.rt_ct_cd = rt_srt.rt_ct_cd 17 and rt_srt.srt_ord > max_srt_ord 18 / Explained. SQL> @?\rdbms\admin\utlxpls PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- Plan hash value: 998396165 -------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 7 | 476 | 11 (19)| 00:00:01 | | 1 | HASH UNIQUE | | 7 | 476 | 11 (19)| 00:00:01 | |* 2 | HASH JOIN | | 7 | 476 | 10 (10)| 00:00:01 | |* 3 | HASH JOIN | | 7 | 238 | 7 (15)| 00:00:01 | | 4 | TABLE ACCESS FULL | OBJ | 6 | 78 | 3 (0)| 00:00:01 | | 5 | TABLE ACCESS FULL | OG_DT | 7 | 147 | 3 (0)| 00:00:01 | PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- |* 6 | VIEW | | 7 | 238 | 3 (0)| 00:00:01 | | 7 | WINDOW BUFFER | | 7 | 147 | 3 (0)| 00:00:01 | | 8 | TABLE ACCESS FULL| RT_SRT | 7 | 147 | 3 (0)| 00:00:01 | -------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("OG_DT"."RT_CD"="RT_SRT"."RT_CD" AND "OG_DT"."RT_CT_CD"="RT_SRT"."RT_CT_CD") 3 - access("OBJ"."OB_ID"="OG_DT"."OR_ID") PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------------- 6 - filter("RT_SRT"."SRT_ORD">"MAX_SRT_ORD") Note ----- - dynamic sampling used for this statement (level=2) 27 rows selected. SQL>
SY.
Published by: Solomon Yakobson on May 7, 2012 16:46
-
How to write the following UPDATE query
I have a table with data as below:
Subscriber IMSI imsi_rank 1 12321 1 1 2312341 2 1 332442 3 1 342 4 1 5 2 23213 1 2 12321 2 2 12312 3 2 4 2 5 Now, the data is dense and continuous for a SUBSRCIBER. Between there is no value for a SUBSCRIBER's IMSI null. However, where one or more IMSI is null, I need to update the table to move the IMSI values to the top of the IMSI_RANK.
Say for example for Subscriber 1, IMSI value 2312341 and 332442 is set to NULL value. So I need to write an application Update or PLSQL that will update the data as below.
Subscriber IMSI imsi_rank 1 12321 1 1 342 2 1 3 1 4 1 5 2 23213 1 2 12321 2 2 12312 3 2 4 2 5 I use 11g.
You cannot perform SQL on any PL/SQL collection type. You need to loop through them and make the change.
-
How to build the query SQL for indexes work based on data - dict.?
Hello
I want to build the index 'create' - statement to all indexes have worked-based on the data dictionary.
For example:
create indexes tab1.ind1
on tab1 (lower (col3), lower (col1), col2, col4)
Tablespace "index."
I know I'll find all needed information views all_indexes, all_ind_columns and all_ind_expressions. During the generation of the create statement for the index of the order of the indexed columns must be correct (the order of the indexed column can be achieved using the "position_colonne" column of seen all_ind_columns and all_ind_expressions). But what would be the best way to provide all the necessary information in the right order?
One way would be a PLSQL procedure that puts it all together - but is it possible to use a single SQL statement?
Any help will be appreciated.
Rgds
JHYou can try using DBMS_METADATA. GET_DDL:
SQL> show user; USER is "TEST" SQL> drop table t; Table dropped. SQL> create table t(x varchar2(10)); Table created. SQL> create index i on t(upper(x)); Index created. SQL> select dbms_metadata.get_ddl('INDEX','I','TEST') from dual; DBMS_METADATA.GET_DDL('INDEX','I','TEST') -------------------------------------------------------------------------------- CREATE INDEX "TEST"."I" ON "TEST"."T" (UPPER("X")) PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS"
-
Hello OTN.
I don't understand why my sql query will pass by in the data model of the BI Publisher. I created a new data model, chose the data source and type of Standard SQL = SQL. I tried several databases and all the same error in BI Publisher, but the application works well in TOAD / SQL Developer. So, I think it might be something with my case so I'm tender hand to you to try and let me know if you get the same result as me.
The query is:
SELECT to_char (to_date ('15-' |)) TO_CHAR(:P_MONTH) | » -'|| (To_char(:P_YEAR), "YYYY-DD-MONTH") - 90, "YYYYMM") as yrmth FROM DUAL
Values of the variable:
: P_MONTH = APRIL
: P_YEAR = 2015
I tried multiple variations and not had much luck. Here are the other options I've tried:
WITH DATES AS
(
Select TO_NUMBER (decode (: P_MONTH, 'JANUARY', '01',))
'FEBRUARY', '02',.
'MARCH', '03'.
'APRIL', '04'
'MAY', '05'.
'JUNE', '06'.
'JULY', '07',.
'AUGUST', '08'.
'SEPTEMBER', '09'.
'OCTOBER', '10',.
'NOVEMBER', '11'.
"DECEMBER", "12."
'01')) as mth_nbr
of the double
)
SELECT to_char (to_date ('15-' |)) MTH_NBR | » -'|| (TO_CHAR(:P_YEAR), 'DD-MM-YYYY') - 90, "YYYYMM")
OF DATES
SELECT to_char (to_date ('15-' |: P_MONTH |)) » -'|| ((: P_YEAR, 'MONTH-DD-YYYY')-90, "YYYYMM") as yrmth FROM DUAL
I'm running out of ideas and I don't know why it does not work. If anyone has any suggestions or ideas, please let me know. I always mark answers correct and useful in my thread and I appreciate all your help.
Best regards
-Konrad
So I thought to it. It seems that there is a bug/lag between the guest screen that appears when you enter SQL in the data model and parameter values, to at model/value data.
Here's how I solved my problem.
I have created a new data model and first created all my settings required in the data model (including the default values without quotes, i.e. APRIL instead "Of APRIL") and then saved.
Then I stuck my sql query in the data model and when I clicked ok, I entered my string values in the message box with single quotes (i.e. "in APRIL' instead of APRIL)
After entering the values of string with single quotes in the dialog box, I was able to retrieve the columns in the data model and save.
In the data tab, is no longer, I had to enter the values in single quotes, but entered values normally instead, and the code worked.
It seems the box prompted to bind the values of the variables when the SQL text in a data model expects strings to be wrapped in single quotes, but no where else. It's a big headache for me, but I'm glad that I solved it, and I hope this can be of help to other institutions.
See you soon.
-
SQL query to retrieve a single record for each employee of the following table?
Hi all
Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.
CREATE TABLE xxc_contact)
empnum NUMBER,
alternatecontact VARCHAR2 (100),
relationship VARCHAR2 (10),
phtype VARCHAR2 (10),
Phone NUMBER
);
insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)
insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)
insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)
insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)
insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)
insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)
expected result:
EmpNum AlternateContact Relationship PhType Phone
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
Thanks in advance.
994122 wrote:
Thank you all, that I got a result
http://www.orafaq.com/Forum/m/620305/#msg_620305
By Lalit Kumar B...
Specifically, the two simple solutions provided were:
1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).
SQL > column alternatecontact format A20;
SQL >
SQL > SELECT empnum, alternatecontact, relationship, phtype, phone
2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))
3 FROM xxc_contact one)
4. WHEN r = 1
/
EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE
---------- -------------------- ---------- ---------- ----------
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.
SQL > SELECT empnum, alternatecontact, relationship, phtype, phone
2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)
3 WHERE phone = rn
4.
EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE
---------- -------------------- ---------- ---------- ----------
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
Kind regards
Lalit
-
Need help to write the SQL query
Hello
Please help me to write a query. My requirement is as below.
Hello
I have a table say XYZ in the following format.
product_id local min_order_quntity
========================================
1 en 10
1 ch 10
2 en 20
2 ch 20
3 en 30
3 ch 30
4 en 40
4 NC 10
Now I want to find the product_id where min_order_quantity is different for cn and locale
now I want the result of the following
product_id local min_order_quantity
=============================================
4 en 40
4 ch 10
This is different for local in and cn for product_id 4 min_order_quantity
min_order_quantity should be the same for both the locale(en,ch) for any product_id.
I want to find the product_id where min_order_quantity is different for ch and fr local
Thank you..Hello
This query should do the job
select * from xyz t1 where exists ( select 1 from xyz t2 where t2.product_id = t1.product_id and t2.locale != t1.locale and t2.min_order_quantity != t1.min_order_quantity );
See you soon
-
How can I write the SQL for this result?
Hello my dear,
Here first of all the script.
the data areCREATE TABLE ACC_TEST( AD_ID NUMBER, AD_NAME VARCHAR2(50), AD_SPM_ID NUMBER); /
I need the following result, when passing a value of Ad_Id. For example I go to 142 then result must beInsert 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);
Database 10 G XESelect 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
Any help will be usefulHello
HamidHelal wrote:
WoW! You are totally my point. How do you understand that? lGuess 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 -
Please send me selection for the following query statement...
FOR I IN 1.9 LOOP
IF shift (i) IS NULL THEN
FOR y IN i + 1.9 LOOP
IF shift (y) IS NOT NULL THEN
(I) shift: shift = (y);
Shift (y): = NULL;
EXIT;
END IF;
END LOOP;
END IF;
END LOOP;
Please how to write the select query to replace the lines of code abovePlease proceed here complete and this code did SHIFT here.
-
How to write the select query for it
Hello
I had an html form and the area I drop down and he needs to select several values in the drop-down box. When I select multiple values then I have to write the query to SQL select statement.
When I try to write the select statement and trying to run I get the error message.
Select * from Table
where emo_no = '1,2,3 '.
That's how I write the query please suggest me how to write the query to select several values in the drop-down box.
Thank you
Use the keyword sql 'in '. If you don't know how, I've heard good things about the book Teach Yourself SQL in 10 Minutes by Ben Forta.
-
How to write a query for the data exchange between two columns?
How to write a query for the data exchange between two columns?
I tried a request, does NOT work.
Thank you.update tmp t1 set t1.m1=t1.m2 and t1.m2=(select t2.m1 from tmp t2 where t2.student_id = t1.student_id)
Published by: user533361 on October 23, 2009 14:04Just plain and simple:
update tmp t1 set t1.m1=t1.m2, t1.m2=t1.m1 /
SY.
-
Need help with SQL for the following logic.
I have a table with 3 columns and the following data:
DATE NAME S_NO
1 ABC1 JANUARY 1, 2001
1 ABC2 JANUARY 10, 2001
1 ABC3
1 ABC4
ABC1 2 1 DECEMBER 2010
ABC2 2
2 ABC3 DECEMBER 10, 2010
2 ABC4 DECEMBER 5, 2010
3 XYZ1 FEBRUARY 1, 2001
3 XYZ2 FEBRUARY 2, 2001
I need to retrieve the value of NAME for each S_NO corresponding to the maximum DATE. In the above example, it will be:
1 ABC2
2 ABC3
3 XYZ2/* Formatted on 9/10/2012 2:50:13 PM (QP5 v5.139.911.3011) */ WITH t AS (SELECT 1 S_NO, 'ABC1' NAME, '1-JAN-2001' dt FROM DUAL UNION ALL SELECT 1, 'ABC2', ' 10-JAN-2001' FROM DUAL UNION ALL SELECT 1, 'ABC3', NULL FROM DUAL UNION ALL SELECT 1, 'ABC4', NULL FROM DUAL UNION ALL SELECT 2, 'ABC1', '1-DEC-2010' FROM DUAL UNION ALL SELECT 2, 'ABC2', NULL FROM DUAL UNION ALL SELECT 2, 'ABC3', '10-DEC-2010' FROM DUAL UNION ALL SELECT 2, 'ABC4', '5-DEC-2010' FROM DUAL UNION ALL SELECT 3, 'XYZ1', '1-FEB-2001' FROM DUAL UNION ALL SELECT 3, 'XYZ2', '2-FEB-2001' FROM DUAL) SELECT * FROM (SELECT S_NO, name, RANK () OVER (PARTITION BY s_no ORDER BY TO_DATE (dt, 'dd-mon-yyyy') DESC) rk FROM t WHERE dt IS NOT NULL) WHERE 1 = RK
-
Query using SQL for the agenda of the source page does not value populated insert
Display as: text field
Type of page element: query SQL
Value Expression: select sysdate double
Element of the page is 'UPDATE_DATE '.
The goal is to 'automatically fill the box' this field with sysdate to the user has to when you complete the form. Problem is that it is automatically generated and I can even see the value when I click on the Sessions, however, when I click on CREATE to insert the row, he returned, "ORA-01400: cannot insert NULL in...» »Hello
Apart from "Type of Source should be the column of database and the Source value must be the name of a column of a table.", you can also use the default: SYSDATE as a PL/SQL Expression
Greetings,
Roel
http://roelhartman.blogspot.com/
You can reward this response in marking it as useful or Correct ;-)
Maybe you are looking for
-
Satellite C660-108 - Windows XP Home Edition does not install
I try to install Windows XP Home Edition on a Toshiba Satellite C660-108, without success. I changed the BIOS disk in "Compatibility" mode (what is the same thing as "Legacy IDE"?) by following the instructions on a Yahoo Answers question on the same
-
Results of change to the package in the lost library
Make the pictures any titles I decided to change all my photos of the opening batch in order to change the file name for the title so both would be identical. However, after this opening cannot find pictures in the Finder - 'Show in Finder' is grey a
-
Saved programs & Docs to a folder on another drive. Made the file READ ONLY so she would not get changed. Windows RELOADED. Copied programs (no longer available and/or damaged discs) and Docs for the new Windows. Now most of the Windows files, progra
-
The host '(SMTP)' could not be found. Please check that you have entered the server name correctly.Subject ' Emailing: BuildEquityFlyer', account: ' POP3 (1)', server: '(SMTP)', Protocol: SMTP, Port: 25, secure (SSL): no, Socket error: 11001, error n
-
How can I get rid of windows 8? It's a junk
I hate windows 8, it took all my programs. How can I go back to my old xp?