Urgent help on date query
select userid,month,year from counter where to_char(month,'MM') ='04'
and to_char(year,'YYYY')='2003'
I am getting error when i ran this query
invalid number format
thanks
The error message appears to indicate your columns are numeric so the query is obviously:
select userid,month,year from counter
where month = 4
and year = 2003
... or am I missing some hidden problem here ?
Similar Messages
-
Need urgent help with the query - Beginer
Hello - I need help with a query to populate data in a table.Here is the scenario.
Source1
MnthID BranchCod CustID SegCode FXStatus ProfStatus Profit
200712 B1 C1 20 Y Y 100
Source2
MnthID BranchCod CustID ProdCode ProdIndex
200712 B1 C1 12 1
200712 B1 C2 12 0
Destination
MnthID BranchCod SegCode ProdCode CountSegCust CountProdCust ProfitProdCust
Condition and Calculations:
1)Source1 customer are base customers.If Source2 has customers who is not in source1 then that customer's record should not be fetched.
2)SegCode, FX Status, ProfStatus is one variable in destination table. [ SegCode = SegCode+ FXStatus (if FXStatus = Y)+ ProfStatus (if FXStatus = Y) ]
3)CountSegCust = CountCustID Groupby MnthID,BranchCod,SegCode Only.
4)CountProdCust = CountCustID Groupby MnthID,BranchCod,SegCode,ProdCode (when ProdIndex = 1)
5)ProfitProdCust = Sum of Profit of Customers Groupby MnthID,BranchCod,SegCode,ProdCode (when ProdIndex = 1)
Apologies for bad formatting.
Thanks in advance!!A total guess indeed.
It's not clear whether some aggregation can be done (summing counts of grouped data might cause some customers being counted more than once)
insert into destination
select mnthid,branchcod,segcode,prodcode,countsegcust,countprodcust,profitprodcust
from (select s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end segcode,
s2.prodcode,
count(s1.custid) over (partition by s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end
order by null
) countsegcust,
count(case proindex when 1
then custid
end
) over (partition by s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end
s2.prodcode
order by null
) countprodcust,
sum(case proindex when 1
then profit
end
) over (partition by s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end
s2.prodcode
order by null
) profitprodcust,
row_number() over (partition by s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end
s2.prodcode
order by null
) the_row
from source1 s1,source2 s2
where s1.mnthid = s2.mnthid
and s1.branchcod = s2.branchcod
and s1.custid = s2.custid
where the_row = 1Regards
Etbin -
Very Urgent Help , ABAP SQL Query
Guys,
Please suggest.I have a table(custom_table1) with a field say A which is of date type = c and length = 9. And i want to query this table.Following is the query.
Select substr(A,0,5) B C into itab From table custom_table1
where b = ( select b from cusstom_table2 )
and substr(A,0,5) = Input_A.
That is i want to equate an Input_A (which is of 5 character length) with field A (only first 5 character of the 9 length). But it seems the query is wrong. Kindly help ,very urgent
ThanksThanks guys, U have helped me to fill up the where condition as
but what about the column A in the select query ?I need only 5 characters from the field populated into Itab.
CONCATENATE srch_str '%' INTO srch_str. -- bcos i want it to be 'InputA%'
Select Substr(A,0,5) , B C Into Itab From CustomTable 1 where B = (Select B from customtable2) and A Like SrchStr
Is there any means i can populate only the 5 characters from the select field A into Itab without using Substr (becos it doesnt work) ? Please help. -
Urgent Help:Tree structured query
Hi,
My requirement is as follows..
I have two tables let's say A and B
Table A has two fileds ID and PARENT_ID
ID is a primary key and Parent_id is a foreign key to the same tables "ID" field(i.e, parent_id references a.id)
Table B has 2 fields : status and id
where ID is a foreign key to table A.id(B.id references A.ID)
The data in those two tables looks like this
A
ID PARENT_ID
1 2
2 3
3 4
4
5 6
6 7
7
Table B has ..
Status id
Approved 1
Approved 2
Now I would like to select all the Approved Ids and all parent_IDs
So i should get the following result
id
1
2
3
4
Can somebody help me write this query.. this is Kinda urgent Please.
Thank yousql>select * from a;
ID PARENT_ID
1 2
2 3
3 4
4
5 6
6 7
7
7 rows selected.
sql>select * from b;
STATUS ID
Approved 1
Approved 2
2 rows selected.
sql>select distinct id
2 from a
3 start with id in (select id
4 from b
5 where status = 'Approved')
6 connect by prior parent_id = id;
ID
1
2
3
4
4 rows selected. -
Need URGENT help on DATA PACKAGE
Hi team,
When we extract the data from the data source it's getting as a package by package before start process i need to add all the packages into one internal table .
How do i do that ?.
Pl help me it's URGENt appreciate your response. thanks.
Regards,
Senthilhi,
you need to do the process in source system or BW.
if it is in source system, extract through program/function module that coolects all the data package and process there and push to BW once procee is over.
if it is to be done in BW- i hope in the start routine u can do only by package by package.
please give ur actual requirment so that others can give suggesstion.
Ramesh -
URgent: Help regarding SQL Query
Hi ,
I need help regarding an sql query.
Sample Data:
ITEM_TYPE ITEM_NUM UNIT_PRICE QUANTITY LINE_TOTAL
ITEM 1 5 10 50
ITEM 2 10 5 50
ITEM 1 5 5 25
ITEM 2 10 20
TAX 16.5
TAX -3.5I would like to display the data as
ITEM_TYPE ITEM_NUM UNIT_PRICE QUANTITY LINE_TOTAL
ITEM 1 5 15 145
2 10 5
2 10
TAX 13.0
Line_total = unit_price * QuantityThanks in Advance
G.Vamsi Krishna
Edited by: user10733211 on Aug 5, 2009 7:42 AM
Edited by: user10733211 on Aug 5, 2009 7:49 AM
Edited by: user10733211 on Aug 5, 2009 8:12 AM
Edited by: user10733211 on Aug 5, 2009 8:22 AM
Edited by: user10733211 on Aug 5, 2009 8:24 AMHi,
Try this, use some analytics:
SQL> with t as (
2 select 'item' item_type, 1 item_num, 5 unit_price, 10 quantity, 50 linetotal from dual union all
3 select 'item', 2, 10, 5, 50 from dual union all
4 select 'item', 1, 5, 5, 25 from dual union all
5 select 'item', null, 2, 10, 20 from dual union all
6 select 'tax', null, null, null, 16.5 from dual union all
7 select 'tax', null, null, null, -3.5 from dual
8 ) -- actual query starts here:
9 select item_type
10 , item_num
11 , unit_price
12 , sum_qty
13 , case when sum_lt = lag(sum_lt) over ( order by item_type, item_num )
14 then null
15 else sum_lt
16 end sum_lt
17 from ( select item_type
18 , item_num
19 , unit_price
20 , quantity
21 , sum(quantity) over ( partition by item_type, item_num ) sum_qty
22 , sum(linetotal) over ( partition by item_type ) sum_lt
23 , row_number() over ( partition by item_type, item_num order by item_type, item_num ) rn
24 from t
25 )
26 where rn=1;
ITEM ITEM_NUM UNIT_PRICE SUM_QTY SUM_LT
item 1 5 15 145
item 2 10 5
item 2 10
tax 13
4 rows selected.
edit
And please use the code tag, instead of clunging with concats.
Read:
http://forums.oracle.com/forums/help.jspa
Edited by: hoek on Aug 5, 2009 5:15 PM
edit2
Also nulls for item_type:
ops$xmt%OPVN> with t as (
2 select 'item' item_type, 1 item_num, 5 unit_price, 10 quantity, 50 linetotal from dual union all
3 select 'item', 2, 10, 5, 50 from dual union all
4 select 'item', 1, 5, 5, 25 from dual union all
5 select 'item', null, 2, 10, 20 from dual union all
6 select 'tax', null, null, null, 16.5 from dual union all
7 select 'tax', null, null, null, -3.5 from dual
8 ) -- actual query starts here:
9 select case when item_type = lag(item_type) over ( order by item_type, item_num )
10 then null
11 else sum_lt
12 end item_type
13 , item_num
14 , unit_price
15 , sum_qty
16 , case when sum_lt = lag(sum_lt) over ( order by item_type, item_num )
17 then null
18 else sum_lt
19 end sum_lt
20 from ( select item_type
21 , item_num
22 , unit_price
23 , quantity
24 , sum(quantity) over ( partition by item_type, item_num ) sum_qty
25 , sum(linetotal) over ( partition by item_type ) sum_lt
26 , row_number() over ( partition by item_type, item_num order by item_type, item_num ) rn
27 from t
28 )
29 where rn=1;
ITEM_TYPE ITEM_NUM UNIT_PRICE SUM_QTY SUM_LT
145 1 5 15 145
2 10 5
2 10
13 13
4 rows selected.If you really need a space instead of nulls, then simply replace the nulls by a space....
Edited by: hoek on Aug 5, 2009 5:18 PM -
Urgent Help with Date and then email in ASP
Hii,
USING ASP AND ACCESS
I am implementing a classified section for my website and I
am displaying
everything successfully.
When the user posts the classified he selects how many days
he wants his
POST like 10 days, 20 days or 30 days and i can successfully
show the posts
So if the user posts on says 1st of July 2006 and selects 10
days for his
post to be showed on my website
THEN
8th July 2006 an email shud go to him saying if he wants to
keep his POST
for another 10 days, 20 days or 30 days with 3 links
and IF YES the 1st july 2006 date must be changed to
Date of Post + Number of days selected initially + Number of
days selected.
I am using two columsn in the DB for this date thing one is
the strPostDate
and strAddDate
So basically the number of days selected for the post to be
shown on the
website keeps adding up each time the user clicks on the link
for 10 days,
20 days or 30 days with 3 links
please help need it badly :-)I have to disagree with my colleages above - this isn't that
hard at all. I have done it a number of times successfully. It does
depend on a "trick", but who cares as long as it works.
Basically, the "trick" says that your site will receive a
visit once in a while! It better, or why have the site!
In ASP, use the global.asa file. In the "Session start"
section of global.asa, which is fired off every time a new comer
arrives, you have an opportunity to:
1. check if it's ok to check who needs an email (in other
words, you don't want to be checking EVERY time someone comines on
board every last listing on your site. So what i would do is allow
it to do the full check once daily, say after midnight.
2. If its ok to check who needs an email, do so, and send the
emails out.
3. After sending out emails, fix it so you will not be
resending uptil teh next time window. You could also set "flags"
for any lister where you sent an email 1st round email has been
sent.
The above is one way.
Sometimes i do the very same thing, but i simply tie the
checking routine into the home page.
Both schemes work as long as you have a single visitor once
in a while. if you never had a visitor to teh site, not even one,
then the emails would never be sent. But as i said if you go days
without a visit, better start looking for a new vocation!
www.brunswickdowntown.com is a site i did that has a
sign-up-to-stay informed email system, its been running for a year
just fine, all automatically, using the method of #1 (but for
asp.net, same difference!)
Rick -
Urgent help in data load ascii
Hi
I have a table with following data
Table A
ID Number(4)
Convert Varhchar2(6)
Values
ID Convert
10 ???
20 10ae
30 2a10
40 (2345
I have a Final Table
Table B
ID number(4)
Convert number(20)
What I need is i need to insert values from table a into Table b
while inserting values into tableb.column
Insert number as number and char and special charaters Using ascii
So for example
If i have data like
TABLEa.Convert Tableb.convert
??? ascii('?')||ascii('?')||ascii('?')
10ae 10||ascii('a')||ascii('e')
Can anybody create a procedure to insert values into tableb
Thanks for all your help
Thanksdeclare
type idtyp is table of number(5) index by binary_integer;
idtab idtyp;
type converttyp is table of varchar2(6) index by binary_integer;
converttab converttyp;
pos number(1);
convertnew varchar2(20);
begin
select id,convert bulk collect into idtab,converttab
from a;
for i in 1..idtab.count loop
pos := 1;
convertnew := '';
for j in 1..length(converttab(i)) loop
if substr(converttab(i),pos,1) not in
('1','2','3','4','5','6','7','8','9','0') then
convertnew := convertnew||ascii(subst(converttab(i),pos,1));
else
convertnew := convertnew||substr(converttab(i),pos,1);
end if;
pos := pos + 1;
end loop;
insert into b values(idtab(i),to_number(convertnew));
end loop;
end; -
Hi,
I wanted to get the Query from View Criteria, please let me know where can i get this query from bean or am.
ThanksThanks for your quick reply puthanampatti.
Here my problem is i need to modifiy my view criteria query bcoz when i am trying to search any result OR clause is appending to query because of this OR clause my query is taking long time to produce result. is there any process to add our query to view criteria?
Please help me. -
Urgent Help Needed Union Query
Hello All
I have a complex query (at least i think) which returns result set. Now i want to add to it the records that were not mached by the query i tried
<Query1>
Union all
<Query2> where not in <query1> (hope i am able to express myself)
but it takes a lot of time
is there any way that query1 is refered once or i have to redefine the query
Any Help ??????
Thanks in advanceI think i am unable to clearly express myself
When i try to use outer join error occures end-of-file on communication channel. actualy i have a poorly designed database structure which is not in my control but i am supposed to report on it
<query1>
union all
<Query2> where not in <query1>
i wanted to say query 1 returns a result set and query 2 reurns rows not selected by query 1
any workaround -
Urgent help needed in Query Find Window
Gurus
In my custom form i have a Query Find Window with three fields. The requirement is when user selects a value ( LOV) from any of the fields the other fields in the Query Find Window should get the relative value. I can acheive this only if i set the AUTOMATIC DISPLAY to yes for the fields. User identified this & they asked me to do this without setting the AUTOMATIC DISPLAY to yes.
I referred someother CUSTOM forms & i did tried but i am unable to achieve this one. Please guide me.
Thanks.In the key-list val trigger itself, you can populate the required information into those fields.
If i am wrong then the requirement is not so clear.
Regards
Balaji -
Urgently help needs on query performance please
HI,
Eache iteration taking four seconds while execution...
What could be the reason for this????
FOR tem_rec IN temp LOOP
UPDATE t_routing_operations_api SET routing= tem_rec.sub_routing
WHERE routing_id=latest_routing_id and routing_id != 3 and routing = tem_rec.routing ;
UPDATE t_next_operations_api SET routing = tem_rec.sub_routing
WHERE routing_id=latest_routing_id and routing_id != 3 and routing = tem_rec.routing;
--COMMIT;
END LOOP;
regards,
Khaleel.Hi there, thank you all for showing the interest in solving my problem....
here I am going bit more clear about my question...
My compete procedure is....
CREATE OR REPLACE
procedure rand_route_gen1 is
CURSOR get_routing_id IS SELECT * FROM t_routings_api WHERE routing_id=3;
CURSOR temp IS SELECT * FROM c_rname_tem;
CURSOR get_operation_id(v_routing_id number) IS SELECT *
FROM t_routing_operations_api WHERE routing_id=v_routing_id;
CURSOR get_next_oper(v_operation_id number) IS SELECT * FROM t_next_operations_api
WHERE operation_id=v_operation_id;
random_no INTEGER:=0;
rt_id INTEGER:=0;
latest_routing_id INTEGER:=0;
BEGIN
DELETE FROM c_rname_tem;
--COMMIT;
INSERT INTO c_Rname_tem SELECT distinct routing,null FROM t_routing_operations_api;
--COMMIT;
FOR routing_rec IN get_routing_id LOOP
FOR c in 2..10 LOOP
FOR tem_rec IN temp LOOP
random_no:=dbms_random.value(1,3);
UPDATE c_rname_tem SET sub_routing='T'||random_no WHERE routing LIKE tem_rec.routing;
END LOOP;
INSERT INTO T_ROUTINGS_API values ('R'||rout_id.nextval,'1000',null,null,'R',rout_id.nextval,null,1,null,'Test Routing'
,null,null,null,null,1,null,'N',null,null,'XL Sheet',null,null,null,null,null,null);
--COMMIT;
SELECT max(operation_id) INTO rt_id FROM t_routing_operations_api;
rt_id:=rt_id+1;
FOR Operation_Rec IN get_operation_id(routing_rec.routing_id) LOOP
IF operation_rec.routing is not null THEN
insert into T_ROUTING_OPERATIONS_API values (rout_id.currval,/*'T'||i,*/operation_rec.routing,null,
null,rt_id,null,null,null,90,null,null,operation_rec.primary_flag,Operation_Rec.operation_rank,null,null,null,null,null,
null,null,null,10,null,null,null,null);
ELSE
insert into T_ROUTING_OPERATIONS_API values (rout_id.currval,null,Operation_Rec.operation,null,rt_id,
null,null,null,90,null,null,operation_rec.primary_flag,Operation_Rec.operation_rank,null,null,null,null,null,null,null,
null,10,null,null,null,null);
END IF;
--commit;
For next_oper_rec in get_next_oper(operation_rec.operation_id) loop
BEGIN
IF next_oper_rec.routing is not null THEN
insert into T_NEXT_OPERATIONS_API values ( rt_id,rout_id.currval,null,null,null,null,
next_oper_rec.operation_rank,null,null,null,null,
/*'T'||i*/
next_oper_rec.routing );
ELSE
insert into T_NEXT_OPERATIONS_API values ( rt_id,rout_id.currval,next_oper_rec.operation,null,
null,null,next_oper_rec.operation_rank,null,null,null,null,null);
--COMMIT;
END IF;
EXCEPTION
when no_data_found then null;
END;
END LOOP;
rt_id:=rt_id+1;
--COMMIT;
SELECT max(routing_id) INTO latest_routing_id FROM t_routings_api;
DBMS_OUTPUT.PUT_LINE(' UPDATE STARTED AT::'||TO_CHAR(SYSDATE,'SSSSS'));
/*THIS BLOCK TAKING TOO MUCH TIME*/
FOR tem_rec IN temp LOOP
UPDATE t_routing_operations_api SET routing= tem_rec.sub_routing
WHERE routing_id=latest_routing_id and routing_id != 3 and routing = tem_rec.routing ;
UPDATE t_next_operations_api SET routing = tem_rec.sub_routing
WHERE routing_id=latest_routing_id and routing_id != 3 and routing = tem_rec.routing;
-- COMMIT;
END LOOP;
--COMMIT;
END LOOP;
--COMMIT;
END LOOP;
END LOOP;
COMMIT;
END;
For in that abouve probedure THE SHOWN BLOCK TAKING AROUND 4 SECONDS FOR EACH ITERATION.
IN THE MAIN TABLES THERE ARE VERY LESS RECORDS, AROUND 15 ROWS. SO FOR ONE MAIN ITERATION ITS TAKING ONE MUNITE THERE ITSELF. SO TO COMPLETE ALL THIS PROCEDURE ITS TAKING AROUND 9 MUNITES...
I HAVE VERY VERY LESS DATA IN THE TABLES.
SO I HOPE IT GIVE YOU CLEAR IDEA FOR YOU. AWITING FOR YOUR REPLIES.....
REGARDS,
KHALEEL. -
Hi, I need to compare two dates, so I can get the difference betweem them in hours.
Try this.. This does it in days but I think you will get the idea..
import java.io.*;
import java.util.*;
import java.text.*;
public class Ex1805
public static void main(String[] args)
SimpleDateFormat sdf = new SimpleDateFormat("d/M/y");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String inputDate;
Date first = new Date(), second = new Date();
final long MSInDay = 1000 * 60 * 60 * 24;
boolean valid;
// input first date
valid = false;
while(!valid)
try
System.out.print("Enter first date: ");
inputDate = br.readLine();
first = sdf.parse(inputDate);
valid = true;
catch(ParseException e)
System.out.println("Invalid date. Please enter again.");
catch(IOException e)
System.out.println("IO Error");
// input second date
valid = false;
while(!valid)
try
System.out.print("Enter second date: ");
inputDate = br.readLine();
second = sdf.parse(inputDate);
valid = true;
catch(ParseException e)
System.out.println("Invalid date. Please enter again.");
catch(IOException e)
System.out.println("IO Error");
// calculate difference in days
long milliseconds = second.getTime() - first.getTime();
double doubleDays = (double)milliseconds / MSInDay;
int days = (int)(doubleDays + 0.5);
System.out.println("Number of days: " + days); -
Urgent help : Meta Data lost
Hi,
We are using our dev server to deploy on different prod server. Recently our server is dead and no way to recover anything from disks because they are all damaged. Even worst, the backups are unreadable and all the Metadata were on dev server.
My question is : is there any way to regenerate OWB Metadata from Runtime environment ?
Thanks for your help.Hi,
there's no way to get the metadata back! :-( If you import the packages from the target database you get them as packages into the repository - not as mappings.
That's why you should backup the metadata - and try to import it again too. ;-)
Regards
Detlef -
Urgent help on SAP BW3.5 GST Query Changes
Dear Experts,
Need your urgent help in modifying a query.
Requirement: The Query has two different hierarchy node structures in 1 hierarchy itself.
This hierarchy is used in report where we can now see 2 different node structures added, for which the calculation of Rate is different for one node and different for another.
Rate = Tax/ GST Val * 100 for first node
Rate = (GST Val /(GST Gross - GST Val)) * 100 for another node.
The differentiating factor for these two nodes is Tax Code which is a char value.
This rate value couldnt been calculated at Report level for the reason being that all others the Key figures except Tax Code which is a char and hence couldnt put any formula there.
We tried calculating the Rate at Cube lebel itself by creating another Key figure and written a 'field level routine' to it, it is working good and showing the right values at cube level, where the data is stored at Line item level.
Now the challenge is that in report, as we execute them at aggregated levels the value for Rate is being cumulated (added) and shown which is wrong.
Eg: Account LineItemNo Input Tax Credit GST GST Rate
123 1 10 10 100
123 2 20 20 100
In Report when we look at these figures it appears at say Account level then it is appearing as :
Account Input Tax Credit GST GST Rate
123 30 30 200 (Instead of 100 as expected).
Can anyone help us to resolve this, this is of top most priority to us.
We are not using any WAD and system is BW 3.5.
Please suggest if WAD can help us in this.
Kind Regards,
RJHi Gerrit Schang,
Thanks for your instant reponse, appreciate it.
But as this is BW3.5 system, the option for Exception Aggregation selection as "no aggregation along the hierarchy" is not available in dropdown.
But there is one option as 'No aggregation (X, if more than one record occurs)' below which there is an option to chose the Agg.ref.char on which this aggregation should be checked.
Can I use this option and select ' Account Number' as the Agg.ref.char to solve my problem?
or you have any other solution, please suggest.
Kind Regards,
RJ
Maybe you are looking for
-
How do I set up a new router for my macbook?
I am living in South Korea and recently just bought a new unicorn router. I followed all of the instructions. I went to the IP address that it listed, typed in all of my IP information that was on my mac and I just can't get it to work. Has anyone el
-
How to create a banner on every page
Hi, I am creating my first website using iWeb. I have a banner that I want to display on every page of the site. At the moment this banner is created from 1 text box and 3 images. I am currently copying and pasting this banner onto every page. This d
-
Can no longer backup with time machine to WD MyBookLive.
Earlier I got the "OSStatus error 2" and now I get a message that the backup failed, "time machine couldn't back up to mybooklive. Unable to complete backup. An error occurred while creating the backup folder." I've signed in as guest, which I have a
-
Spry Menu-overlapping submenu items
Hello, I am new to Dreamweaver. I created a horizontal spry menu and one of my items has a submenu which contains two items. When I look at the page in live view or preview it in a browser, the two submenu items overlap. How do I fix this? I have tri
-
Bought iPhone 5. Really disappointed. Within 2 days, alert sounds and typing sounds are not working. Camera is terrible. My old HTC One S was far superior!