October 3, 2013 at 12:11 am
Please provide me the condition on which your filter statement will be .
Lets say
condition 1
filter should be $filter = '1'
condition 2
filter should be $filter = '2'
then I can make the statement for you.
Thanks,
October 3, 2013 at 12:13 am
we go with condition 1..
Thanks
Shobana
October 3, 2013 at 12:18 am
Hi,
Sorry you didn't understood my question.
Just provide me original query and let me know what condition you want there in "Where" condition then I can help you.
Thanks,
October 3, 2013 at 1:22 am
select distinct split_part(split_part(cp.msg, 'src=',1),',',1),split_part(split_part(cp.msg, 'user=''',2),',',1) as user ,am.itime,am.dtime,am.url from "FGT60B3908669009-wlog-1380091698" am join "SYSLOG-C0A80A41-glog-1380347892" cp on cast(am.src as character varying)=cast((split_part(split_part(cp.msg, 'src=',2),',',1) ) as character varying) where am.src='192.168.10.23' and replace('$filter', 'itime', 'am.itime')
This is my original query.................
Thanks,
October 3, 2013 at 1:55 am
Ok what you actually trying to do by this:
replace('$filter', 'itime', 'am.itime')
?
It may be some condition like itime>=something or item<=something right ?
October 3, 2013 at 2:59 am
exactly.
if the user wants the reports for 1hr...
this query has to generate 1hr report..
Thanks,
Shobana
October 3, 2013 at 3:10 am
If you have two different conditions like am.time <= and am.time>= then better to write if else statement and copy paste your query with required modifications.
I am not able to help you as I still could not understand your requirement.
Sorry π
October 3, 2013 at 3:20 am
Thanks a lot for your help
Replacement every thing over. Now if i run the below query its querying for long time due to huge datas in DB(PostgreSQL). if i run same query outside i am getting test data's quickly. Now tell me how to get quick datas.
Since here we are splitting,joining, comparing,with the the timestamp we have to give the result.
So it takes time to pull the datas.............
DROP TABLE IF EXISTS OwnerMessageList1;
CREATE TEMPORARY TABLE OwnerMessageList1 (
id serial,
name varchar(100)
);
INSERT INTO OwnerMessageList1
(name)
select unnest(string_to_array(replace(replace('$filter', 'itime >= ', ''),'itime <= ',''),'and'));
select distinct split_part(split_part(cp.msg, 'src=',2),',',1),split_part(split_part(cp.msg, 'user=''',2),',',1) as user ,am.itime,am.dtime,am.url from "FGT60B3908669009-wlog-1380091698" am join "SYSLOG-C0A80A41-glog-1380347892" cp on cast(am.src as character varying)=cast((split_part(split_part(cp.msg, 'src=',2),',',1) ) as character varying) where (cast(am.itime as varchar)<=(select name from OwnerMessageList1 where id=1) and cast(am.itime as varchar)>=(select name from OwnerMessageList1 where id=2));
Thanks,
Shobana:blink:
October 3, 2013 at 3:37 am
Is this PostgreSQL?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 3, 2013 at 3:40 am
yup
October 3, 2013 at 3:42 am
Is it possible to use webserver and get connected to DB to get quick results
Thanks,
Shobana
October 3, 2013 at 3:44 am
You can directly write your value in below sub query.
This sub query may lead to some problem like multiple records in select statement error etc.
where (cast(am.itime as varchar[highlight=#ffff11])<=(select name from OwnerMessageList1 where id=1)[/highlight] and cast(am.itime as varchar)>=([highlight=#ffff11]select name from OwnerMessageList1 where id=2)[/highlight]);
Here I can suggest only this things π
Hope this may help.
October 3, 2013 at 3:52 am
ERROR: syntax error at or near "highlight".
LINE 12: ...character varying)where (cast(am.itime as
This is the error i am getting
Thanks
shobana
October 3, 2013 at 3:57 am
what is highlight?
Thanks,
Shobana
October 3, 2013 at 4:08 am
remove this from your code
[highlight=#ffff11]
and
[/highlight]
This is added by SQLServerCentral's editor
Use constants instead of subquery.
Viewing 15 posts - 16 through 30 (of 35 total)
You must be logged in to reply to this topic. Login to reply