Difficulty writing query
how do i write query query from a table columns? For example the below query retrun the following....
Query:-
select 'select ( sum ( vsize ('||column_name ||'))' from dba_tab_columns where table_name = 'SAP_LONE_TEXT';
Result:
'SELECT(SUM(VSIZE('||COLUMN_NAME||'))'
select ( sum ( vsize (EMPLID))
select ( sum ( vsize (UCX_BATCH_SEQ))
select ( sum ( vsize (BRANCH))
select ( sum ( vsize (EXT_ORG_ID))
select ( sum ( vsize (EXT_SUMM_TYPE))
select ( sum ( vsize (UNT_TYPE))
select ( sum ( vsize (UNT_COMP_TOTAL))
select ( sum ( vsize (EXT_GPA))
select ( sum ( vsize (CONVERT_GPA))
9 rows selected.
I need output like this...
SELECT ( SUM ( VSIZE (EMPLID))
+ SUM ( VSIZE (UCX_BATCH_SEQ))
+ SUM ( VSIZE (BRANCH))
+ SUM ( VSIZE (EXT_ORG_ID))
+ SUM ( VSIZE (EXT_SUMM_TYPE))
+ SUM ( VSIZE (UNT_TYPE))
+ SUM ( VSIZE (UNT_COMP_TOTAL))
+ SUM ( VSIZE (EXT_GPA))
+ SUM ( VSIZE (CONVERT_GPA))
)/1024/1024 "Total Size in Mega Bytes"
FROM 'SAP_LONE_TEXT';
how do I write a query?....
Thanks in advance.
I am not getting query...
SELECT "Table Name",||DECODE (ROWNUM,
1, 'select ( sum ( vsize (' ||
column_name || '))',
' + sum ( vsize (' || column_name ||
b_columns
WHERE table_name in ('EMP','DEPT','INVENTORY')
NION ALL
SELECT ')/1024/1024 "Total Size in Mega Bytes" FROM
in ('EMP','DEPT','INVENTORY');'
FROM DUAL;
SQL> SELECT "Table Name",||DECODE (ROWNUM,1, 'select ( sum ( vsize (' || column_name || '))',
2 ' + sum ( vsize (' || column_name || '))')
3 FROM all_tab_columns
4 WHERE table_name in ('EMP','DEPT','INVENTORY')
5 UNION ALL
6 SELECT ')/1024/1024 "Total Size in Mega Bytes" FROM in ('EMP','DEPT','INVENTORY');'
7 FROM DUAL;
SELECT "Table Name",||DECODE (ROWNUM,1, 'select ( sum ( vsize (' || column_name || '))',
ERROR at line 1:
ORA-00936: missing expressionare you not getting any row or are you getting an error?
Similar Messages
-
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
Need helping in writing query for finding percentage of duration
Can any one please help in writing query for this.
The table is like this :-
ID Region Month Duration
I1 R1 Jan 80
I2 R2 Jan 70
I3 R1 Jan 70
I4 R3 Jan 40
I5 R1 Feb 80
I6 R2 Feb 30
I7 R3 Mar 100
I want to write a query to find
% of duration for each and every region against each and every month.
Please help in solving this query. I am in urgent need of this.
Thanks in advance.I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
Nicolas. -
Hi,
Could anyone help me in writing below query without syntax errors.
I tried but no luck
select xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
(select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A"))
as "A" from
(SELECT g.contentgroup_id AS id, g.groupname AS label, c.title AS label, c.content_id AS id
FROM content_ec c FULL OUTER JOIN contentgroup_ec g ON c.group_id = g.contentgroup_id
oRDER BY g.groupname ,c.title ASC );
Any help really appreciated.
ThanksFew tips to get your question answered here
1. Give your database version. Some thing that does not work in one version works fine in the next. And 8i,9i or 10g is not version. best way to give the version is to query your v$version table like this.
SQL> select * from v$version where rownum = 1
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod2. You should understand we don't have what you have, meaning you should provide your data structure and some sample data for us to help.
3. "I got an error"... "Its not working"... and the list goes on. Sentences like this does not help. If you got a error past the entire error. If stuff does not work, tell us the details.
4. Just don't throw some output and say i want it. Please explain to every one how you derive it.
5. And the most important thing. Use \...\ tag to format. Please.. Please.. Please.. use it. It helps every one a lot. When you use it your SQL looks some thing like this.
SELECT xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
(select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A")) as "A"
FROM (SELECT g.contentgroup_id AS id,
g.groupname AS label,
c.title AS label,
c.content_id AS id
FROM content_ec c
FULL OUTER JOIN contentgroup_ec g
ON c.group_id = g.contentgroup_id
ORDER BY g.groupname ,c.title ASC );6. And also do search this forum. Most of your my queries are answered by simple search.
Thanks,
Karthick. -
PROBLEM IN WRITING QUERY.
HI FRIENDS,
I AM TRYING TO WRITE A QUERY WHICH WILL RETURN ME DATE QUATER WISE.
SUPPOSE I HAVE A DATE 19-SEP-12 THEN IT WILL CONSIDER THIS DATE BETWEEN FINANCIAL YEAR 2012-2013 AND THE RETURN ME DATE LIKE
01-APR-12 TO 30-JUN-12
01-JUL-12 TO 31-SEP-12
01-OCT-12 TO 31-DEC-12
01-JAN-13 TO 31-MAR-13
PLEASE HELP ME IN WRITING THE QUERY.Hi,
If
TRUNC (date_column, 'Q')is the beginning of quarter x, then
ADD_MONTHS ( TRUNC (date_column, 'Q')
, 3
)is the beginning of quarter x+1, and
ADD_MONTHS ( TRUNC (date_column, 'Q')
, 3
) - 1is the last day of quarter x.
The expression above is midnight at the beginning of the last day of quarter x; be careful if you use it in a BETWEEN expression. -
Assistance in writing Query / Query Logic.
I have a peculiar requirement to fetch data.
Table Structure ( Sample ... although real table has more fields)
Order ( orderid varchar2(30), custid varchar2(30), status varchar2(1), createdon datetime )
Sample Data:
OrderID CustID AccID Status createdon
123 111 Y 20-Jan-2012 01:29:22
124 111 100 Y 22-Jan-2012 01:23:02
125 111 100 N 23-Jan-2012 02:34:24
126 111 100 N 28-Jan-2012 04:23:22
127 111 100 N 29-Jan-2012 07:32:26
123Cancel 111 100 N 31-Jan-2012 03:27:29
I want to write 2 Queries.
a. input is OrderId, Need to find out how many order's present with status = 'N' after that orderid provided.
b. input is OrderId, Need to find out what is the previous order with status = 'Y'
Note: There can be 100's of orders and Status would be Y on first come first serve basis... if one does not have status = 'Y' ie it is 'N' the following order's will never turn to final status = 'Y'.
There are millions of records in the table.
Your help for writing this query / logic would be highly appreciated. Am intending to do thru single query.
Best Regards
MH Doshiselect count(*) from order
where createdon >( select created from order where order_id = &order_id);
and status = 'N';
select * from (select a.*, rownum rn from (select order_id from order
where status = 'Y'
and createdon<(seelect createdon from order where order_id = &order_id)
order by createdon)) where rn=1 -
Writing query using UNION Operator
Question -
(1)
Write an SQL Statement to list the following items: Customer ID, Customer Name, number of invoices, sum of total for invoices. Ensure that all customers are returned in the result set.
Answer for the above is written as below by one person. That seams to be correct. Is there another way of writing this same query.;
select c.CUSTOMER_ID,c.NAME,i.cnt,i.s
from gee_customer c,(select customer_id,count(*) as cnt, sum(TOTAL) as s
from gee_invoice
group by customer_id) i
where c.CUSTOMER_ID = i.customer_id (+)
(2)
My other question is How to write the above answer (or what you sugest) using UNION operator ?
Any ideas please
Message was edited by:
user483578In fact the outer join means you use the union of two result sets - usual join result
and the rows from the outer table for which there is not any row in the inner table.
SQL> select d.deptno, e.ename from emp e, dept d
2 where d.deptno = e.deptno(+)
3 order by 1,2
4 /
DEPTNO ENAME
10 CLARK
10 KING
10 MILLER
20 ADAMS
20 FORD
20 JONES
20 SCOTT
20 SMITH
30 ALLEN
30 BLAKE
30 JAMES
30 MARTIN
30 TURNER
30 WARD
40
15 rows selected.
SQL> select d.deptno,e.ename from emp e, dept d
2 where d.deptno = e.deptno
3 union
4 select deptno, null
5 from dept d where not exists (select null from emp e where e.deptno = d.deptno)
6 order by 1,2
7 /
DEPTNO ENAME
10 CLARK
10 KING
10 MILLER
20 ADAMS
20 FORD
20 JONES
20 SCOTT
20 SMITH
30 ALLEN
30 BLAKE
30 JAMES
30 MARTIN
30 TURNER
30 WARD
40
15 rows selected.In your example something like (NOT tested !)
with i as (select customer_id,count(*) as cnt, sum(TOTAL) as s
from gee_invoice group by customer_id)
select c.CUSTOMER_ID,c.NAME,i.cnt,i.s
from gee_customer c, i
where c.CUSTOMER_ID = i.customer_id
union
select c.CUSTOMER_ID,c.NAME,null,null
from gee_customer c
where not exists (select null from i where c.CUSTOMER_ID = i.customer_id)
Rgds. -
Trouble writing Query for Pivoting data from a table
I am having a little trouble writing a query for converting the below table data into a pivot data. I am trying to write a query for which if I give a single valid report_week date as input it should give me the data for that week and also provide two extra columns, one which gives the data of last week for the same countries and the second column which gives the difference of numbers in both the columns(i.e. COUNT - COUNT_LAST_WEEK).
REPORT_WEEK DIVISION COUNT
9/26/2009 country1 81
9/26/2009 country2 97
9/26/2009 country3 12
9/26/2009 country4 26
9/26/2009 country5 101
10/3/2009 country1 85
10/3/2009 country2 98
10/3/2009 country3 10
10/3/2009 country4 24
10/3/2009 country5 101
10/10/2009 country1 84
10/10/2009 country2 98
10/10/2009 country3 10
10/10/2009 country4 25
10/10/2009 country5 102
For example, if I give input as 10/10/2009, the output should be as give below.
REPORT_WEEK DIVISION COUNT COUNT_LAST_WEEK DIFFERENCE
10/10/2009 country1 84 85 -1
10/10/2009 country2 98 98 0
10/10/2009 country3 10 10 0
10/10/2009 country4 25 24 1
10/10/2009 country5 102 101 1
For example, if I give input as 10/3/2009, the output should be as give below.
REPORT_WEEK DIVISION COUNT COUNT_LAST_WEEK DIFFERENCE
10/3/2009 country1 85 81 4
10/3/2009 country2 98 97 1
10/3/2009 country3 10 12 -2
10/3/2009 country4 24 26 -2
10/3/2009 country5 101 101 0
Can anyone please shed some light on Query building for the above scenarios.
Thank you
SKP
Edited by: user11343284 on Oct 10, 2009 7:53 AM
Edited by: user11343284 on Oct 10, 2009 8:28 AMI assume there is no gap in report weeks. If so:
SQL> variable report_week varchar2(10)
SQL> exec :report_week := '10/10/2009'
PL/SQL procedure successfully completed.
with t as (
select to_date('9/26/2009','mm/dd/yyyy') report_week,'country1' division,81 cnt from dual union all
select to_date('9/26/2009','mm/dd/yyyy'),'country2',97 from dual union all
select to_date('9/26/2009','mm/dd/yyyy'),'country3',12 from dual union all
select to_date('9/26/2009','mm/dd/yyyy'),'country4',26 from dual union all
select to_date('9/26/2009','mm/dd/yyyy'),'country5',101 from dual union all
select to_date('10/3/2009','mm/dd/yyyy'),'country1',85 from dual union all
select to_date('10/3/2009','mm/dd/yyyy'),'country2',98 from dual union all
select to_date('10/3/2009','mm/dd/yyyy'),'country3',10 from dual union all
select to_date('10/3/2009','mm/dd/yyyy'),'country4',24 from dual union all
select to_date('10/3/2009','mm/dd/yyyy'),'country5',101 from dual union all
select to_date('10/10/2009','mm/dd/yyyy'),'country1',84 from dual union all
select to_date('10/10/2009','mm/dd/yyyy'),'country2',98 from dual union all
select to_date('10/10/2009','mm/dd/yyyy'),'country3',10 from dual union all
select to_date('10/10/2009','mm/dd/yyyy'),'country4',25 from dual union all
select to_date('10/10/2009','mm/dd/yyyy'),'country5',102 from dual
select max(report_week) report_week,
division,
max(cnt) keep(dense_rank last order by report_week) cnt_this_week,
max(cnt) keep(dense_rank first order by report_week) cnt_last_week,
max(cnt) keep(dense_rank last order by report_week) - max(cnt) keep(dense_rank first order by report_week) difference
from t
where report_week in (to_date(:report_week,'mm/dd/yyyy'),to_date(:report_week,'mm/dd/yyyy') - 7)
group by division
order by division
REPORT_WE DIVISION CNT_THIS_WEEK CNT_LAST_WEEK DIFFERENCE
10-OCT-09 country1 84 85 -1
10-OCT-09 country2 98 98 0
10-OCT-09 country3 10 10 0
10-OCT-09 country4 25 24 1
10-OCT-09 country5 102 101 1
SQL> exec :report_week := '10/3/2009'
PL/SQL procedure successfully completed.
SQL> /
REPORT_WE DIVISION CNT_THIS_WEEK CNT_LAST_WEEK DIFFERENCE
03-OCT-09 country1 85 81 4
03-OCT-09 country2 98 97 1
03-OCT-09 country3 10 12 -2
03-OCT-09 country4 24 26 -2
03-OCT-09 country5 101 101 0
SQL> SY. -
Hi All,
I have following query to execute at every 20 seconds interval for one day.
si.pos_txn_date between to_date('01-DEC-2011 21:20:01','DD-MON-YYYY HH24:MI:SS')
and to_date('01-DEC-2011 21:40:00','DD-MON-YYYY HH24:MI:SS')
This parameter i want to increment by every 20 sec like if i have executed once for above then at net time it must take above condition as
si.pos_txn_date between to_date('01-DEC-2011 21:40:01','DD-MON-YYYY HH24:MI:SS')
and to_date('01-DEC-2011 22:00:00','DD-MON-YYYY HH24:MI:SS')
How should i do that?
query is as follows
insert into temp_lyris_02dec
with base as(
SELECT
ea.third_party_order_ref ,
DECODE(ea.title,'MR','M','MR.','M','MISS','F','MRS','F','MRS.','F','MS.','F','Unknown') AS male_female,
ea.email_address,
ea.first_name || ' ' || ea.surname AS fname_sname,
ea.title,
ea.first_name,
ea.surname,
hpk_lookup.hsf_get_hoflin@nrstp(si.rp_rp_id) AS hoflin,
si.rp_rp_id RP_ID,
wcs.wc1_descr AS level1,
wcs.wc2_descr AS level2,
wcs.wc3_descr AS level3,
wcs.wc4_descr AS level4,
wcs.wc5_descr AS level5,
rpcv.descr AS brand,
wp.short_brief,
si.sales_item_val,
si.txn_val,
TO_CHAR(si.pos_txn_date, 'DD-MON-YYYY HH24:MI:SS') AS order_date,
ea.billing_address1,
ea.billing_address2,
ea.billing_address3,
ea.billing_postcode,
ea.billing_country,
si.recogn_card_no,
ilv.first_order_date,
CASE
WHEN ef.numrecs > 0 THEN
'Y'
ELSE
'N'
END cardholder_flag
FROM dwt_sales_items si
INNER JOIN dw_retl_prd_cat_val_us rpcvu ON si.rp_rp_id =
rpcvu.rp_rp_id
AND si.sales_audit_date BETWEEN
rpcvu.dw_eftv_from AND
NVL(rpcvu.dw_eftv_to,
si.sales_audit_date)
INNER JOIN dw_retl_prd_cat_vals rpcv ON rpcvu.pc_pc_id = rpcv.pc_pc_id
AND rpcvu.pcv_pcv_id = rpcv.pcv_id
AND si.sales_audit_date BETWEEN
rpcv.dw_eftv_from AND
NVL(rpcv.dw_eftv_to,
si.sales_audit_date)
INNER JOIN web_prds@nrstp wp ON si.rp_rp_id = wp.rp_rp_id
LEFT JOIN dss.dwt_om_email_addresses ea ON si.loc_loc_id = ea.loc_loc_id
AND si.till_no = ea.till_no
AND TRUNC(si.pos_txn_date) =
ea.transaction_date
AND si.sales_audit_txn_no =
ea.sales_audit_txn_no
--INNER JOIN web_sales@nrstp ws
--ON ea.third_party_order_ref = ws.dmw_order
INNER JOIN web_cats@nrstp wc ON REPLACE(retail.hsf_wc_highest_level@nrstp(si.rp_rp_id,
TRUNC(si.pos_txn_date)),
'S',
'') = wc.wc_id
INNER JOIN wcs@nrstp wcs ON wc.art_wc_id = wcs.wc_art_wc_id
LEFT OUTER JOIN (SELECT dt.loc_loc_id,
dt.till_no,
dt.sales_audit_date,
dt.sales_audit_txn_no,
COUNT(*) numrecs
FROM dwt_tenders dt
WHERE dt.sales_audit_date = '02-DEC-2011' --''14-JUL-2011''
AND dt.seme_seme_id IN
('06', '16', '70', '71', '78', '79', '80', '81', '86', '87','84')
GROUP BY dt.loc_loc_id,
dt.till_no,
dt.sales_audit_date,
dt.sales_audit_txn_no) ef ON ef.loc_loc_id =
ea.loc_loc_id
AND ef.till_no =
ea.till_no
AND ef.sales_audit_date =
trunc(ea.transaction_date)
AND ef.sales_audit_txn_no =
ea.sales_audit_txn_no
-- INNER JOIN (SELECT third_party_customer_ref,
LEFT OUTER JOIN (SELECT third_party_customer_ref,
MIN(transaction_date) AS first_order_date
FROM dss.dwt_om_email_addresses
GROUP BY third_party_customer_ref) ilv ON ea.third_party_customer_ref =
ilv.third_party_customer_ref
WHERE si.sales_audit_date = '02-DEC-2011' --'14-JUL-2011'
AND si.loc_loc_id = '1097'
AND rpcvu.pc_pc_id = 'BRAND'
AND si.qual_cd = '10'
AND si.sales_item_val >= 0
and si.pos_txn_date between to_date('01-DEC-2011 21:20:01','DD-MON-YYYY HH24:MI:SS')
and to_date('01-DEC-2011 21:40:00','DD-MON-YYYY HH24:MI:SS')
AND NVL(si.rsn_rsn_class, 'X') <> 'RETURNS'),
cards as
(select oea.third_party_order_ref,
si.rp_rp_id,
si.recogn_card_no,
si.loc_loc_id,
si.till_no,
si.sales_audit_date,
si.sales_audit_txn_no,
case
when bn.account_type in ('RFC','STR','STI') then
'Y'
else
'N'
end REC_AC_FLAG,
case
when bn.account_type in ('CDT','CDI') then
'Y'
else
'N'
end REC_MC_FLAG,
case
when bn.account_type in ('LTY','LYI') then
'Y'
else
'N'
end REC_REW_1_FLAG,
case
when bn.account_type in ('LTT') then
'Y'
else
'N'
end REC_REW_2_FLAG,
case
when bn.account_type in ('LTY','LYI') then
'Y'
else
'N'
end REC_REDEMPTION_FLAG
from dss.dwt_om_email_addresses oea, dwt_sales_items si,crm_bin_numbers@crmenq bn, base
where oea.loc_loc_id = si.loc_loc_id
and oea.till_no = si.till_no
and oea.transaction_date = trunc(si.pos_txn_date)
and oea.sales_audit_txn_no = si.sales_audit_txn_no
and si.sales_item_val > 0
and si.recogn_card_no is not null
and si.recogn_card_no like bn.bin_number||'%'
and si.sales_audit_date = '02-DEC-2011' --'14-JUL-2011'
and si.rp_rp_id = base.RP_ID
and oea.third_party_order_ref = base.third_party_order_ref),
tndr as
( select t.loc_loc_id,t.till_no,t.sales_audit_date,t.sales_audit_txn_no,
sum(t.txn_seme_val) - t.txn_val As sum_val
from dwt_tenders t
where t.sales_audit_date = '02-DEC-2011' --'14-JUL-2011'
group by t.loc_loc_id,t.till_no,t.sales_audit_date,t.sales_audit_txn_no, t.txn_val
-- Here the main select statement goes for with query
select base.third_party_order_ref,
base.male_female,base.email_address,base.fname_sname,base.title,base.first_name,
base.surname,base.hoflin,base.level1,base.level2,base.level3,base.level4,base.level5,
base.brand,base.short_brief,base.sales_item_val,base.txn_val,base.order_date,
base.billing_address1,base.billing_address2,base.billing_address3,base.billing_postcode,base.billing_country,
base.recogn_card_no,base.first_order_date,base.cardholder_flag,
case
when tndr.sum_val = 0 and cards.REC_AC_FLAG = 'Y' then
'Y'
else
'N'
end REC_AC_FLAG,
case
when tndr.sum_val = 0 and cards.REC_MC_FLAG = 'Y' then
'Y'
else
'N'
end REC_MC_FLAG,
case
when cards.REC_REW_1_FLAG = 'Y' then
'Y'
else
'N'
end REC_REW_1_FLAG,
case
when cards.REC_REW_2_FLAG = 'Y' then
'Y'
else
'N'
end REC_REW_2_FLAG,
case
when tndr.sum_val = 0 and
regexp_like(cards.recogn_card_no,
'^(6338070|6338071|6338072)[0-9]*$') then
'Y'
else
'N'
end GIFT_CARD_FLAG,
case
when tndr.sum_val = 0 and cards.REC_REDEMPTION_FLAG = 'Y' then
'Y'
else
'N'
end REC_REDEMPTION_FLAG,
dwsf_delv_method(base.third_party_order_ref) as Delivery_method,
dwsf_store_type(base.third_party_order_ref) as Stores,
dwsf_cust_id_mv(base.recogn_card_no) As Customer_id
from base left join cards on base.RP_ID = cards.rp_rp_id
and base.third_party_order_ref = cards.third_party_order_ref
left join tndr on tndr.loc_loc_id = cards.loc_loc_id
and tndr.till_no = cards.till_no
and tndr.sales_audit_date = cards.sales_audit_date
and tndr.sales_audit_txn_no = cards.sales_audit_txn_no;I don't see the difficulty.
declare
v_start date := to_date('01-DEC-2011 21:20:01','DD-MON-YYYY HH24:MI:SS');
v_end date := to_date('01-DEC-2011 21:40:00','DD-MON-YYYY HH24:MI:SS');
begin
while v_start_date < v_end_date
loop
<put your sql statement here>
v_start_date := v_start_date + (1*20)/24/60/60);
end loop;
end;PS. Your example seems to show 20 minute differences
if you want this then use this instead
v_start_date := v_start_date + (1*20)/24/60; -
Get 15 mins back time from current time (pls help writing query)
Dear all,
I need to write a query that gives time 15 mins before the current time.
I need to calculate hits on a website for last 15 mins.
Kindly help writing this query.
Regards, Imranselect sysdate - 15/(60*24)
from dual;
Regards
Asif Kabir -
Writing query to Oracle DB with DATE field in it.
When I try to execute the following query on Oracle DB I get an exception. I know that the problem is with Date representation on the query string. Please, if anyone knows how to make it work help me.
query = "INSERT INTO MYTABLE (NAME , BIRTHDAY ) VALUES ('" + person.getName() +" ' , " + person.getBirthday() + " )";
statment.executeUpdate(query);
getBirthday() returns java.sql.Date object.
Please, please, help to work it out!Thank you, very much.
I've put the record into DB!!!! Hurray!
But now I have another problem. I've got a ResultSet & I'd like to extract the DATE from it. But how?
The Exception text states that the name of the field (Birthday) is incorrect.
My code:
Date birthday = resultSet.getDate("Birthday");
All other fields are perfectly well extracted, but they are Strings. -
hii all
i have a form on which i have a customer_name field
it is a non database field
i am getting the value of the customer_name field from customer id .
but the customer _id field is not on the form
i want to query the form based on the customer name
like in the customer_name field i would query 'm%'
but customer_name being non database it is not allowing me to query
please help me to query it if it is possible
thanks in advance
Message was edited by:
bindok mulgaHi,
If U want in Sql Write the query like this :
Select * from Table_Name Where Customer_Name Like 'M%';
Other Wise If U want On Customer_Name Text Write The Query In Post text item of the Customer_Name Like:
I Hope Table Name Is Customer_Dir ,?
Declare
Result Number;
M_Red_Color Varchar2(100) := Get_Item_Instance_Property(:System.Current_Block||'.'||:System.Current_Item, Current_Record, Visual_Attribute);
Begin
If :Customer_Dir.Customer_Name is not null then
:Customer_Dir.Customer_Name := Ltrim(:Customer_Dir.Customer_Name);
Begin
Select Customer_Cd Into :Customer_Dir.Customer_Cd
From Customer_Dir
Where Customer_Name= :Customer_Dir.Customer_Name;
<<M_LOOP>>
Loop
Bscil.Show_Message('Bscil_stop', 'Entry ' ||:Customer_Dir.Customer_Name || ' Does Not Exist. (Please check your entry) ', Null, 'Ok', Null, Null, Result);
If Result = Alert_Button1 Then
Bscil.Set_Item_Color(:System.Current_Block||'.'||:System.Current_Item, 'RED_COLOR');
Raise Form_Trigger_Failure;
Exit M_Loop;
End If;
End Loop;
Exception
When No_Data_Found Then Null;
End;
Else
:Customer_Dir.Customer_Cd := Null;
End if;
If M_Red_Color = 'RED_COLOR' Then
Bscil.Set_Item_Color(:System.Current_Block||'.'||:System.Current_Item, 'WHITE_COLOR');
End If;
End; -
Dear All,
How to write a Query in a SQ01. Please tell me the steps with an example.
Its very urgent.
Thanks & Regards,
Abhay.Hi,
Check this out.
http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Introduction.asp
Reward if helpful.
Regards,
Ramya -
Writing query in frame!!
hi
Im developing a form in which i have been using BC4J.Currently my frame need a simple sql statement to fetch record from DB.since im using BC4J,do i need to open new connection to execute this query?.do we have any method to execute query??I have to execute query based on the values retrived from combobox.
Thanks in advance!!!
nullAssuming that your frame uses BC4J, and you are going against a predefined rowset:
rowSetInfo.setQueryCondition( whereClauseString);
rowSetInfo.setQueryOrderbyClause( orderByClauseSTring);
rowSetInfo.executeQuery();
may be helpful to you. I build a string dynamically based on textfield, checkbox and combobox entries for a custom Find panel.
Do Help on rowsetinfo.
Hope that helps
null -
APD - writing query result "rank calculation" to file or DSO
Hello,
I am trying to take a query result set where I am calculating a key figure as Rank and run it through an APD to write to a DSO.
This is a top 5 query for a dashboard. I keep getting an MDX failure on the query.
Any ideas?
My ultimate goal is to set up a process to take TopN query results and get them into a target that can be used in a Universe.
Thanks,
ChrisHi,
You want to store the data of query in to dso?Y
You can write a code in to routine for calulated key figure.
I also face the same problem but i solved using routine.
try this.
Regards,
Ganesh
Maybe you are looking for
-
Hi Expert, How can I track the original and received batch when performing MT 309. My scenario is to transfer Material A with batch X to Material A with batch Y. What report or functionality to track the batch? Best regards, Mahnansa
-
Hi All, We are facing strange problem in LSO in displaying the course catalog properly for all users. We are using mySAPERP 2005 (ECC 6.0) SP11. LSO 600 FE, We are using structural authorization profiles in the R/3. The catalog was displaying the cat
-
I used to have a Smiley Central icon on the MyWebSearch task bar. While updating my computer with a new router, that task bar disappeared, along with my Smiley Central icon. When I go to Smiley Central to download again, all I get is the page for a c
-
Oracle 9i Data Guard Documentation
Hi, I am trying to get documentation on Oracle 9i Data Guard. When I am at this url: http://www.oracle.com/technology/deploy/availability/htdocs/DataGuardOverview.html I then activate the link on the right for "Oracle 9i Data Guard Documentation". Ho
-
Merge 4411462 and 5073249 patches?
Performing EBS database upgrade from 9.2 to 10G: Step 21 of note:362203.1 says to apply 9 database patches. Two of the patches in the list conflict with each other (4411462 and 5073249). How did you guys handle this? Did you skip the 5073249 patch an