analytical, where condition moved to select clause
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64biPL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
AMT for Linux: release 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
Hello! I run the following code, but I want to set the condition "CONTRACT_DATE BETWEEN' under SELECTION. Unfortunately, I got different results.
Thank you in advance.
WITH T
AS (SELECT 1 CONTRACT_NO,
TO_DATE ('1/2/2012', 'DD/MM/YYYY') CONTRACT_DATE,
1000 PRICE
FROM DUAL
UNION ALL
SELECT 1 CONTRACT_NO,
TO_DATE ('2/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
50 PRICE
FROM DUAL
UNION ALL
SELECT 1 CONTRACT_NO,
TO_DATE ('3/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
150 PRICE
FROM DUAL
UNION ALL
SELECT 2 CONTRACT_NO,
TO_DATE ('4/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
75 PRICE
FROM DUAL
UNION ALL
SELECT 2 CONTRACT_NO,
TO_DATE ('3/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
900 PRICE
FROM DUAL)
SELECT CONTRACT_NO, MAX (PRICE) OVER (PARTITION BY CONTRACT_NO) MAX_PRICE
FROM T
WHERE CONTRACT_DATE BETWEEN TO_DATE ('2/9/2012', 'DD/MM/YYYY')
AND TO_DATE ('3/9/2012', 'DD/MM/YYYY')
output:
1 150
1 150
2 900
What I tried was:SELECT CONTRACT_NO,
CASE
WHEN CONTRACT_DATE BETWEEN TO_DATE ('2/9/2012', 'DD/MM/YYYY')
AND TO_DATE ('3/9/2012', 'DD/MM/YYYY')
THEN
MAX (PRICE) OVER (PARTITION BY CONTRACT_NO)
END
MAX_PRICE
FROM T
1
1 1000
1 1000
2
2 900
/* Formatted on 1/21/2013 5:39:48 AM (QP5 v5.139.911.3011) */
WITH T
AS (SELECT 1 CONTRACT_NO,
TO_DATE ('1/2/2012', 'DD/MM/YYYY') CONTRACT_DATE,
1000 PRICE
FROM DUAL
UNION ALL
SELECT 1 CONTRACT_NO,
TO_DATE ('2/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
50 PRICE
FROM DUAL
UNION ALL
SELECT 1 CONTRACT_NO,
TO_DATE ('3/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
150 PRICE
FROM DUAL
UNION ALL
SELECT 2 CONTRACT_NO,
TO_DATE ('4/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
75 PRICE
FROM DUAL
UNION ALL
SELECT 2 CONTRACT_NO,
TO_DATE ('3/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
900 PRICE
FROM DUAL)
SELECT CONTRACT_NO,
MAX (
CASE
WHEN CONTRACT_DATE BETWEEN TO_DATE ('2/9/2012', 'DD/MM/YYYY')
AND TO_DATE ('3/9/2012', 'DD/MM/YYYY')
THEN
PRICE
END)
OVER (PARTITION BY CONTRACT_NO)
MAX_PRICE
FROM T
1 150
1 150
1 150
2 900
2 900
Or you need exactly what makes your first request, but you are not satisfied with the performance?
SY.
Tags: Database
Similar Questions
-
How can I avoid hard-coding where the internal this select clause?
It is extremely fast, but I have to hardcode the more where clause and I obviously can't do. I know how to get around it by creating a function that takes the CUSTOMER_ID and returns the ORDER_ID for the most recent payment, and it's pretty fast, but I thought it would be interesting to see if there was a way to do this in SQL directly. I also know that better design could make the problem go away.
Really appreciate it if you could take a look and let me know if it is possible to get this kind of performance without Hardcoding.
Thank you
create or replace view customer_view as
Select customer.customer_id,
Customer.Customer_name,
(
Select t.order_id
de)
Select payment.order_id
payment
where payment.customer_id = 1 - <-here's the line where I hardcode the customer_id. is possible to reference the customer_id without this hard-coding?
payment.payment_date desc order
) t
where rownum = 1
) as latest_order_id
of the customer
;
Select * from customer_view where customer_id = 1; <-I want that inner - most select this option to use this customer_id, without having to hardcode it.Hi Matt,
Something like that could be a possibility (untested)
create or replace view customer_view as select customer.customer_id, customer.customer_name, (select min (t.order_id) keep (dense_rank first order by payment.payment_date desc) from payment where payment.customer_id = customer.customer_id) as latest_order_id from customer;
Concerning
Peter -
Based where conditional clause...
dear team, i have following code.. Declare gv_flag1 Varchar2(1) := 'N'; gv_flag2 Varchar2(1) := 'N'; gv_flag3 Varchar2(1) := 'N'; all_where1 Varchar2(250); all_where2 Varchar2(250); ALL_where3 Varchar2(250); V_QTY Number; Begin If gv_flag1 = 'N' Then all_where1 := 'AND '||'V.OWNER = ''PROD'''; End If; DBMS_OUTPUT.PUT_LINE(all_where1); If gv_flag2 = 'N' Then all_where2 := 'AND '||'V.OPERATION NOT LIKE (''10%'')'; End If; DBMS_OUTPUT.PUT_LINE(all_where2); If gv_flag3 = 'N' Then all_where3 := 'AND '||'V.OPERATION NOT LIKE (''07%'')'; End If; DBMS_OUTPUT.PUT_LINE(all_where3); --select based on conditions.. End; NOW I want where conditions in select statment to be conditional... which means if flag1='N' and flag2 = 'N' then use both all_where1 and all_where2 in *where* clause statement... if flag1='N' and flag3 = 'N' then then use all_where1 and all_where 3 in *where* clause of select statement... if all there flag = 'N' then use all_where conditions in *where* clause of select statement... i have 3 flags, which means total of 9 combinations, is there any simpler way to do such kind of thing?? please assist me nic
Nicloei W wrote:
Hi Jeenesh,What happens if Flag2 = 'Y' and Indicateur3 = 'Y' in this case, I want only the condition with Flag1
concerning
NICSQL> ed Wrote file afiedt.buf 1 Declare 2 gv_flag1 Varchar2(1) := 'N'; 3 gv_flag2 Varchar2(1) := 'Y'; 4 gv_flag3 Varchar2(1) := 'Y'; 5 --all_where1 Varchar2(250); 6 --all_where2 Varchar2(250); 7 --ALL_where3 Varchar2(250); 8 lc_query varchar2(1000):= 'select count(*) from test v '; 9 lc_where varchar2(500) := ' where 1 = 1 '; 10 V_QTY Number; 11 Begin 12 If gv_flag1 = 'N' Then 13 lc_where := lc_where||' AND V.OWNER = ''TEST'''; 14 End If; 15 If gv_flag2 = 'N' Then 16 lc_where := lc_where||' AND V.OPERATION NOT LIKE ''10%'''; 17 End If; 18 If gv_flag3 = 'N' Then 19 lc_where := lc_where||' AND V.OPERATION NOT LIKE ''07%'''; 20 End If; 21 lc_query := lc_query||lc_where; 22 dbms_output.put_line(lc_query); 23 dbms_output.put_line('-----------'); 24 execute immediate lc_query into v_qty; 25 dbms_output.put_line('Count: '||v_qty); 26* End; SQL> / select count(*) from test v where 1 = 1 AND V.OWNER = 'TEST' ----------- Count: 3 PL/SQL procedure successfully completed.
-
Condition within a where condition clause
Dear friends,
I am a beginner in PL/SQL and I need your help.
I'll show you my code (it does not):
My problem is here:declare var_mese VARCHAR2 (2); begin select max(to_number(MESE)) into var_mese from NOC_MONITORAGGIO; SELECT count(*) FROM noc_sdoc_work a, noc_sdoc b, NOC_MONITORAGGIO WHERE NVL(a.CD_STRUTTURA,'x') = NVL(b.CD_STRUTTURA,'x') AND NVL(a.CD_SUB_STRUTTURA,'x') = NVL(b.CD_SUB_STRUTTURA,'x') AND NVL(a.NR_PRATICA,'x') = NVL(b.NR_PRATICA,'x') AND NVL(a.ASL,'x') = NVL(b.ASL,'x') AND b.STATO IN ( 1, 2 ) and if var_mese in ('03','04','05','06','07','08','09','10','11','12') then NOC_MONITORAGGIO.ANNO_GESTIONE = b.ANNO; else NOC_MONITORAGGIO.ANNO_GESTIONE = to_number(b.ANNO)-1; end if; end;
I need a nested where conditionand if var_mese in ('03','04','05','06','07','08','09','10','11','12') then NOC_MONITORAGGIO.ANNO_GESTIONE = b.ANNO; else NOC_MONITORAGGIO.ANNO_GESTIONE = to_number(b.ANNO)-1; end if;
Thank you
LeoYou can code box that using a statement in the WHERE clause:
and NOC_MONITORAGGIO.ANNO_GESTIONE = case when var_mese in ('03','04','05','06','07','08','09','10','11','12') then b.ANNO else to_number(b.ANNO)-1 end
-
Shot summary of a where condition clause...
I have a form that displays the code material and this number in which different warehouses...
It is possible to create an element of the summary screen is based on the place where the condition
for ex.
Published by: Chase Suhail on November 9, 2010 22:45SQL> select sum(arar) from tbs; SUM(ARAR) ---------- 1488 for this query i can create a display item and in the propery pallete i can select mode as summary, summary function as count, and select respective block and item... what i want to know is can this be based on where condition some thing like the count shoudn't include where the column values is zero SQL> select count(arar) from tbs where arar!='0'; COUNT(ARAR) ----------- 144
Hello
Create a column of formulas no database in the same block to say 'NON_ZERO.
The formula for the column would be: SET_NON_ZERO - this function returns 1 if arar is non-zero and 0 if it is zero.FUNCTION SET_NON_ZERO RETURN NUMBER IS BEGIN IF :ARAR = 0 THEN RETURN (0); ELSE RETURN (1); END IF; END;
Now you can create a column of synthesis and use the text-to-speech function 'sum' and item summarised as "NON_ZERO.
I hope this helps.
Best regards
Arif Khadas
-
SQL only: WHERE Condition pulled the correct runtime of the Central "SQL" tab
I have a requirement that seems like it should be easy to solve in SQL, but me seems to be stuck with blinders and can't see the solution.
The 'problem' that I'm trying to solve is to get several reporting units to any use of the SQL even in their where clause for certain types of metrics reports. So this is the solution I am proposing that we store the sql in a central table, which, in a simplified form, would have two columns as:
GroupName Varchar2 (2000)
SQL_Filter Varchar2 (5000)
What I want to do conceptual, it's allow the user (even if they're using MS - SQL) to
WHERE FunctionName (GetSQL_ForGroupName)
But first of all, I would tell them that this can be done in Oracle sql. However, I can't understand how to achieve this end. From what I've read so far that oracle will not do:
WHERE (subquery that returns SQL)
or (in SQL)
WHERE VariableSubstition
or
WHERE FunctionName (GetSQL_ForGroupName)
It seems that these things in the WHERE clause allows Oracle after only
FieldName [operator]
as in
WHERE price > (subquery)
or
WHERE ID IN (Value) Function
Is it possible to do a subquery (or anything else) that allows me to draw the where clause running SQL - using only SQL? I can do this with a stored procedure, but it is to say it seems to me I had start coding select specific instructions for them or code so that they could enter select statements (or joins etc.). I don't want to write a complete dynamic reporting engine. I want to do is be able to pull the sql running. This ensures that everyone is 1) with the good sql for metrics 2) by using the same sql and 3) the core sql parameters can be stored in one place instead of 3000 definitions of the various reports.
I must be looking at this the wrong way, I think. The solution does NOT seem to do WHERE (pull in the SQL running)... but I was not able to find a different way of thinking. For example, WITH does not resolve as you immediately the requirement WHERE fieldname [operator] [subquery | function]. I was browsing the internet and looking through all the books SQL on Safari of O'reilly but I have not met a solution. However, I think, this issue of 'centralization of base SQL' must have been resolved several, several times previously. Why can't I find anything on it then?
BradYou might use a pipeline function to return a TABLE object. This function accepts a parameter that contains the name of the Group (although "GetSQL_ForGroupName" is supposed to represent). The query that they deliver will then look something like this:
SELECT column_list FROM TABLE(table_function('GroupName')) WHERE additional_conditions
In the function, you can create the SELECT statement that channels the rows in the table with WHERE conditions pulled a table for the provided group name.
-
dynamice where the Cursor For loop clause
Hi all
I have a cursor based as logic:
FOR temp IN (SELECT colname FROM WHERE whereconditions mytablename)
loop
.
.
.
end loop;
Is there anyway that I can do the whole dynamic WHERE clause?
My where clause should exist only when a certain condition is met. Please help me.
Thank you
ChaitanyaNo, it wouldn't. Performance of:
open temp for 'select clause' loop fetch into.. exit when (temp%notfound); merge logic.... end loop;
would be no different from:
for rec in cur loop merge logic.... end loop;
SY.
-
Understand the dynamic conditions in which the clause
Hi all
I have a requirement where I need to dynamically register the conditions in which the clause based on the variable binding.
My condition is like that.
SELECT f.scheduled_date, a.bld_id, a.room_id, a.cage_id, f.test_num
OF feeding_test_results f.
v_onl_gf_anmls one
WHERE f.sak_feeding_test_res > 5000000
AND f.anml_id (+) = a.anml_id
AND f.bld_id = 'A5 '.
AND f.room_id > 0
AND f.cage_id > '0'
-case when: check_value = 1 Then
"AND scheduled_date < = 16 April 2009"
' AND scheduled_date > = 6 April 2009.
On the other
AND scheduled_date = April 16, 2009"
End
AND f.feeding_status <>'X') f
Kindly somebody help me how to do this.
Thank you and best regards,
P. Gesret Devimichaels2 wrote:
and scheduled_date <= case when :check_value = 1 then date '2009-04-16' end and scheduled_date >= case when :check_value = 1 then date '2009-04-06' end and scheduled_date = case when not :check_value = 1 then date '2009-04-16' end
Hmmm, maybe you want some NVL around these statements of cases such as...
and scheduled_date <= NVL(case when :check_value = 1 then date '2009-04-16' end,scheduled_date) and scheduled_date >= NVL(case when :check_value = 1 then date '2009-04-06' end,scheduled_date) and scheduled_date = NVL(case when not :check_value = 1 then date '2009-04-16' end,,scheduled_date)
or something like this. Otherwise the comparisons with null will just because all this to fail.
-
WHERE condition in a sql statement
Hello people,
I have a screen with data grid where one of the columns is STATES_CODES and other VOLUMES one. Grid consists of several lines. I need to create a CUSTOM SEARCH field that will be filtering on this database.
Unfortunately a customer wants to enter a search string with custom functions: '+' (plus) to include in the selection of the result and "-" (less) to exclude from the selection of the results. For example: "+ IT + -100". Based on this string, I need to return only the States HE and and exclude volumes with a value of 100.
A tip how to build a query where condition, so it will be more effective as possible?
Simple example:
test data:
with t (select 'IT' State, volume 90 of any union double
Select 'IT' State, 100 volumes of all the double union
Select 'IT' State, 100 volumes of all the double union
Select 'OF' State, 90 volume of all the double union
Select 'OF' State, in 100 volumes of all the double union
Select 'OF' State, in 100 volumes of all the double union
Select 'NL' State, 90 volume of all the double union
Select 'NL' State, 100 volumes of all the double union
Select 'NL' State, 100 volumes of all the double union
Select 'FR' State, 90 volume of all the double union
Select 'FR' State, in 100 volumes of all the double union
Select 'FR' State, in 100 volumes of all the double union
Select 'ARE' State, 90 volume of all the double union
Select 'ARE' State, in 100 volumes of all the double union
Select 'ARE' State, 100 volumes of double
)
Select * from t
Search string: "+ IT + - 100".
I thought to somehow using regular expressions REGEXP_LIKE condition, but do not know how to change the entered search string in above format as long as the regular expression.
And if you want to be specific about the characters representing the State and the numbers represent the amount then you will need to divide them into more...
SQL > with t (select 'IT' State, 90 volume of all the double union)
2 Select 'IT' State, 100 volumes of all the double union
3 select 'IT' State, 100 volumes of all the double union
4. Select 'FROM' State, 90 volume of all the double union
5. Select 'FROM' State, in 100 volumes of all the double union
6. Select 'FROM' State, in 100 volumes of all the double union
7 select 'NL' State, 90 volume of all the double union
8 select 'NL' State, 100 volumes of all the double union
9 select 'NL' State, 100 volumes of all the double union
10. Select 'FR' State, 90 volume of all the double union
11. Select 'FR' State, in 100 volumes of all the double union
12. Select 'FR' State, in 100 volumes of all the double union
13. Select 'ARE' State, 90 volume of all the double union
14 select 'ARE' State, in 100 volumes of all the double union
15 select 'ARE' State, in 100 volumes of double
16 )
17, ch. as (select "+ IT + -100"as the double criterion)
18, split as (select regexp_substr (trim (', ' regexp_replace (criteria,'([+ -]) ', ', \1')), "[^,] +', 1, level") as a criterion of)
19 c
20 connect the regexp_substr (trim (', ' regexp_replace (criteria,'([+ -]) ', ', \1')), "[^,] +', 1, level") is not null
21 )
22, inc_state as (select substr(criteria,2) as a criterion
23 split
where the 24 regexp_like(criteria,'^\+[A-Z]+')
25 )
26, inc_vol as (select substr(criteria,2) as a criterion
27 split
where the 28 regexp_like(criteria,'^\+[0-9]+')
29 )
30, exc_state as (select substr(criteria,2) as a criterion
31 split
where the 32 regexp_like(criteria,'^\-[A-Z]+')
33 )
34, exc_vol as (select substr(criteria,2) as a criterion
35 split
where the 36 regexp_like(criteria,'^\-[0-9]+')
37 )
38-
39 select *.
40 t
where the 41 (exists (select 1
inc_state 42
43 where inc_state.criteria = t.state
((44) or (select count (*) in inc_state) = 0)
45 and (exists (select 1
46 by inc_vol
where the 47 inc_vol.criteria = t.volume
((48) or (select count (*) in inc_vol) = 0)
49 and (not exists (select 1
50 to exc_state
where the 51 exc_state.criteria = t.state
((52) or (select count (*) in exc_state) = 0)
53 and (not exists (select 1
exc_vol 54
where the 55 exc_vol.criteria = t.volume
((56) or (select count (*) in exc_vol) = 0)
57.ST VOLUME
-- ----------
HE 90
90 -
explain query plan uses no unique index with where condition
Hi all
I use in the 10.2.0.5 oracle database Enterprise edition 64-bit on 64-bit windows server 2008.
I'm following this tutorial on my own table
Guide to understanding Oracle QUERY PLAN - 10 minutes
my questions are below
Analyze table LIB_CLASSIFICATIONS compute statistics; explain plan for SELECT class_id FROM lib_classifications WHERE class_no = '538' ; select * from table(dbms_xplan.display);
the result is less than
Hash value of plan: 3022072076
-----------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1. 10. 5 (0) | 00:00:01 |
|* 1 | TABLE ACCESS FULL | LIB_CLASSIFICATIONS | 1. 10. 5 (0) | 00:00:01 |
-----------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
1 - filter ("CLASS_NO" = '538')
DESC LIB_CLASSIFICATIONS
Name of Type Null
----------------- -------- -------------
CLASS_ID NOT NULL NUMBER (10)
CLASS_DESC VARCHAR2 (50)
REMARKS VARCHAR2 (250)
CLASS_NO VARCHAR2 (20)
CLASS_TYPE VARCHAR2 (10)
CREATE_USER VARCHAR2 (10)
MODIFY_USER VARCHAR2 (10)
CREATE_DATE DATE
MODIFY_DATE DATE
CLASS_CATEGORY_ID VARCHAR2 (10)
class_id has a primary key.
now when I remove the condition where the query, the result is lower;
Analyze table LIB_CLASSIFICATIONS compute statistics; explain plan for SELECT class_id FROM lib_classifications ; select * from table(dbms_xplan.display);
the result is less than
Hash value of plan: 262704430
------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1558. 6232. 2 (0) | 00:00:01 |
| 1. FULL RESTRICTED INDEX SCAN FAST | SYS_C005653 | 1558. 6232. 2 (0) | 00:00:01 |
------------------------------------------------------------------------------------
now it's using indexes with INDEX FAST FULL SCAN.
I need the index using the WHERE condition as well.
How to do this?
Thank you.
you have indexes on the column class_id not on class_no column how u would expect index to use when there is no index on the column class_no
-
Hello
Doc Oracle says the following on the identifiers in the SELECT in PL/SQL clause: there is no possibility of ambiguity in the SELECT clause because any identifier in the SELECT clause must be a database column name.
If we assume that only valid column identifier are allowed in the SELECT clause.
But I tried the following:
DECLARE toto NUMBER := 10; tata NUMBER := 0; BEGIN SELECT toto INTO tata FROM employees WHERE employee_id = 101; DBMS_OUTPUT.PUT_LINE(tata); END; /
And there is no error telling me that toto is not a column in the employees table and the result is the same as: toto: = aunt;
Won't the doc or did I just miss something?
Thanks for your response!
Hello
rep0ne wrote:
Hello
Doc Oracle says the following on the identifiers in the SELECT in PL/SQL clause: there is no possibility of ambiguity in the SELECT clause because any identifier in the SELECT clause must be a database column name.
If we assume that only valid column identifier are allowed in the SELECT clause.
Post a link to this Oracle doc.
But I tried the following:
- DECLARE
- Toto NUMBER: = 10;
- Auntie NUMBER: = 0;
- BEGIN
- SELECT toto IN Auntie FROM Employees WHERE employee_id = 101;
- DBMS_OUTPUT. Put_line (Auntie);
- END;
- /
And there is no error telling me that toto is not a column in the employees table and the result is the same as: toto: = aunt;
...
You're right that toto is an identifier, but this isn't a column name. (Of a subquery) column alias are not database of the names of columns either, nor are the names of the user-defined function.
Also, there is a possibility for ambiguity even if all the names are the database column names.
Won't the doc or did I just miss something?
I can't say until I see the doc you're talking about.
Oracle documentation is sometimes misleading and sometimes just plain wrong. For each mistake outright example that I saw in the docs of Oracle, there might be 20 cases where the meaning is unclear or misleading and maybe 200 where I just read it wrong.
-
How to add a where condition to seeds VO
Hi I have a VO PoRequisitionLinesVO.Now knowledge I want to add the SQL where condition...
How can I do this...? There is no addition of all fields... only adding a where condition clause?
Will I need to extend that VO? If yes then how should I do this?
Thank you...
Yes, you must extend the VO.
To get the procedure you can search the Internet, there is a great article (that I mentioned below):
https://blogs.Oracle.com/prajkumar/entry/eo_based_vo_extension_in
Kind regards
Sandeep M.
-
Decimal separator in the SELECT Clause
Hello
I have the following parameters of decimal number:
SQL > select value
2 from v$ nls_parameters
3 where parameter = "NLS_NUMERIC_CHARACTERS;
VALUE
----------------------------------------------------------------
,.
If I show a decimal number, I get a comma as decimal separator
SQL > select 10/100 double;
10/100
----------
1
But if I use a decimal separator in the SELECT clause, I get:
SQL > select 100 * 1.1 double;
100 * 1 1
---------- ----------
1 100
It does not work. But the use of a period as the decimal separator works:
SQL > select 1.1 * 100 double;
1.1 * 100
----------
110
Maybe it's something that I never had to deal with before, but I thought that the number format applied to results of sql, as well as the numbers you have used sql clauses.
Kind regards
Nestor BoscanHi, Nestor,
user594312 wrote:
... I thought that the number format applied to results of sql, as well as the numbers you have used sql clauses.No.; it applies to the results and it can affect implicit conversions, but it does not apply to the SQL code.
The period (or dot, '.') is the decimal separator in literals always digital. There is no way to change this.Think how confusing it would be if it applied to the SQL code. For example:
WHERE num_col IN (1,2)
We compare num_col values 1 or 2? He comes in, what happens if we wanted to do the opposite?
If you really want to use the comma as the decimal separator, you may have to use strings, not numbers, and it could be much less effective.
For example:SELECT 100 * TO_NUMBER ('1,1') -- This assumes your NLS settings are correct FROM dual;
Of course, the effectiveness will not be a problem when you select 1 row of double.
-
instead of update, I want to incorporate in the select clause
instead of separate update, I want to incorporate in the select clause.
I use the following version
=====================
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
AMT for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
=============================
create table SpendBy AS NOLOGGING
SELECT commodities.commodity_level_1 mkt_sec.
0 AS mkt_sec_id,-instead of update, I want to integrate it in the select clause
Commodities.commodity_level_2 mkt_sub_sec
TO spend,
commodities
WHERE (spend.commodity_id = commodities.node_id)
Update SpendBy set mkt_sec_id = (select node_id from products where commodity_level_2 is null and commodity_level_1 = SpendBy.mkt_sec);
commit;I'm sorry, should have better considered in your code.
A then:
create table SpendBy NOLOGGING AS SELECT c.commodity_level_1 mkt_sec, select node_id as mkt_sec_id from commodities c2 where c2.commodity_level_2 is null and c2.commodity_level_1=c.commodity_level_1, c.commodity_level_2 mkt_sub_sec FROM spend s, commodities c WHERE s.commodity_id = c.node_id;
-
with different same DataBlock where condition
Hello
I use forms 6i and 10g db.
I have a datablock, say product_master, which retrieves columns product_id, product_name and price.
and I have 2 control blocks (2 tables)
what I want is based on list in 2 blocks of different control items, I need to retrieve data from the datablock
say ctrlblk1 has a listitem named 'pdtlst '.
so in this case where condition to be - WHERE the product_id =: pdtlst
and in ctrlblk2 have another element of list "edpdtlst."
where condition will - WHERE the product_id =: edpdtlst
Is this possible?
I found a "WHERE Clause" option in the Palette property of the Datablock.But I want to spend the condition based on the ctrlblock
Pls helpHello
Changing the block where clause with:
-- numeric column -- Set_Block_property( 'block_name', DEFAULT_WHERE, 'col1=' || :ctrl.item1 ) ; -- char column -- Set_Block_property( 'block_name', DEFAULT_WHERE, 'col1=''' || :ctrl.item1 || '''') ;
François
Maybe you are looking for
-
G62Notebook HP G62-341NR PC: G62-341NR
The problem is that the video light keeps going on this unit. Actually I Can shine a flashlight and you can see what is on the screen, but it's as if there is a blackout on it. I don't know what the problem is or how to fix it. He does intermittently
-
Could not reconnect all network drives
My laptop is getting the message "Could not reconnect all network drives", at startup. I'm running Windows XP, service pack 3. I have a 'Z' allocated network drive, which is marked 'memory_card '. Must this drive be connected? If so, what are the ste
-
I initially added to the next station, which was launched by PaulB_2011: http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-windows_update/cumulative-security-update-for-Internet-Explorer-8/a31ac13a-72f6-4a76-A229-aa3804644a19 However, in
-
TrackIR does not work in Microsoft fsx.
Original title: trackir FSX demo FSX is listed in the rundown of the Trackir 5 titles. It does work for me in the trial version that I just downloaded. I was thinking of buying FSX, but if the trackir will not work it is not worth, any suggestions? I
-
As I search for clues as to why my machine did not come yesterday or today that I have to look at the power switch and try again (the local host has been corrupted since plant), I noted the following in the event log: Ready installation: the followin