How to find a string from a set of records?
I am having a stored procedure which is used for creating a crystal report. When I run the stored procedure sometimes it gives more than one row of data. I want to check if a particular string exists in any row of a particular column. To make it clear let me give an example
When I run the query I get the below columns
Part Part type
A001 Blanket
A002 Blanket
A003 Toys
What I want to check is if Toys is appearing in any of the row in a formula in crystal reports.
Thanks
Sreejith J
Hi,
If you want to check a particular sub string or part of a string within a string, you can try this:
if instr(<database column>, <String to be searched>) = 1 then true
So, your formula output will be true if the <string to be searched> is part of your <database field>.
Thanks,
Raghavendra
Similar Messages
-
How to select a row from duplicate set of records?
I want to select a row from a duplicate set of records.
below is the explanation of my requirement.
select * from test_dup;
COL_BILL COL_SERV COL_SYS
b1 s1 c
b1 s1 g
b1 s2 c
b1 s2 g
b2 s2 g
b2 s3 c
b2 s3 g
b3 s3 c
Here what I want is, for a distinct col_sys if col_bill and col_serv is same then I need the row where col_sys='c'
from the above result set I need the following:
b1 s1 c
b1 s2 c
b2 s3 c
I am using the following SQL query which is giving me the correct result set. But it will hamper the performance because there are total 45 columns in the table and total volume is around 50 million.
select * from test_dup where col_bill||col_serv in (
select col_bill||col_serv from (
select col_bill,col_serv,count(*) from test_dup
where col_sys in ('c','g')
group by col_bill,col_serv having count(*) >1)) and
col_sys='c';
Can anyone please provide me the optimize SQL query for the same.Hi,
Another way,
SQL> with test_dup
as
select 'b1' col_bill, 's1' col_serv, 'c' col_sys from dual union all
select 'b1', 's1', 'g' from dual union all
select 'b1', 's2', 'c' from dual union all
select 'b1', 's2', 'g' from dual union all
select 'b2', 's2', 'g' from dual union all
select 'b2', 's3', 'c' from dual union all
select 'b2', 's3', 'g' from dual union all
select 'b3', 's3', 'c' from dual
select col_bill, col_serv, min(col_sys) col_sys
from test_dup
where col_sys in ('c', 'g')
group by col_bill, col_serv
having count( * ) > 1
and count(nullif(col_sys, 'g')) > 0;
CO CO C
b1 s1 c
b2 s3 c
b1 s2 c
3 rows selected.Regards
Peter
Edited by: Peter on Feb 18, 2009 1:10 AM
- Added test data, thanks Karthick -
How to search a string from the database?
how to search a string from the database? starting with some character
If you're trying to do this in a SELECT, you can use the LIKE verb in your WHERE clause.
Here's an Example
SELECT obj_name FROM tadir
INTO prog
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name LIKE 'Z%'.
In this case it will select every row that obj_name starts with Z.
If you wanted to find every row that the field obj_name contains say... 'WIN' you use LIKE '%WIN%'.
Edited by: Paul Chapman on Apr 22, 2008 12:32 PM -
How to find out the save as setting information in illustrator cs3?
How to find out the save as setting information in illustrator cs3 through programmatically. I saved the file using the setting like Overprint, EmbedAllFonts, IncludeDocumentThumbnails throgh scripting. But i don't know how to find out the save as setting information(Overprint, EmbedAllFonts, IncludeDocumentThumbnails) whether the checkbox true or not through scripting. Kindly advice me.
Thanks for your response. Some time the operator will set the wrong "save as setting" in the eps file . So i need to check wheather the operator set the correct save as setting or not. If the operator set the wrong save as setting, i need to inform while running the script. So please advice me how to find out the save as setting information of the active document file, and then inform to the operator if any improper "save as setting" occured.
-
How to find delete message from iphone
how to find delete message from iphone?
I am afraid that I don't think there is a way to do this.
-
How to convert a string from upper case to lower case in FOX formula
Hi Experts,
How to convert a string from upper case to lower case in FOX formula?
Thanks,
Cheers!!!
PANKAJThe last result.append( c ) should be:
result.append( Character.toLowerCase(c) ); -
How to convert a string from lower case to upper case withour using transla
Hi all,
how to convert a string from lower case to upper case withour using translate,
Thanks in Advance,
ReddyRefer to this related thread
Re: hi guys this very urgent please help -
How to transfer a string from sub sequence to main sequence
Hi,
How to transfer a string from sub sequence to main sequence, My main sequence has included a sub sequence, the sub sequence is return a string value after running done, I need to get this string value from sub sequence to main sequence, I check the defined that look like seem the two
sequence have themself local variable,but I don't know how to defined a globe variable to cover main sequence and sub sequence like VC++'s Main App ,Please kindly help me,thanks in advance...Hi,
I hope this small example will help you.
Regards
Ray Farmer
Regards
Ray Farmer
Attachments:
Sequence File1.seq 36 KB -
How to read a string from file & assign the val to a variable in batch file
Hi,
How to read a string from a file and assign the value to a variable then return the value to the screen in windows batch file?
Any suggestions?
thanks.Unless this is a homework question then I don't see the purpose of doing this, but....
You should be looking a the supplied package utl_file to get the string out of the file, dbms_output to display the string and then google windows batch/command files calling sqlplus to execute your program.
Andre -
How to build a String from Date?
How to build a String from class Date?
How to get the year, month, day, hour ... from a Date object.Ok to build a string use this function in java.util.Date
toString()
TO get year, date, etc u can use the following functions
getYear()
getDate()
This link might help u more
http://java.sun.com/products/jdk/1.1/docs/api/java.util.Date.html -
How to find server model from 11g OEM mgmt$ views
How to find server model from 11g OEM mgmt$ views
server model like Dell 710, DL380 G7 etc..,It is included in this query (run as user SYSMAN):
SELECT t.target_name AS host_name,
ecm_util.HOST_HOME_LIST (t.target_name, t.target_type) AS home_info,
hw.vendor_name AS Vendor,
hw.system_config AS System_Config,
hw.machine_architecture Architecture,
os.name AS os_name,
os.base_version os_base_version,
os.update_level os_update_level,
os.address_length_in_bits os_address_length_in_bits
FROM mgmt_targets t, mgmt_ecm_snapshot s, mgmt_hc_os_summary os, MGMT_HC_HARDWARE_MASTER hw
WHERE t.target_type = 'host'
AND t.target_name = s.target_name
AND s.snapshot_type = 'host_configuration'
AND s.target_type = 'host'
AND s.is_current = 'Y'
AND s.snapshot_guid = os.snapshot_guid
AND hw.snapshot_guid = s.snapshot_guid
ORDER by t.target_type
The asked info is available in the view MGMT_HC_HARDWARE_MASTER, column: SYSTEM_CONFIG
Eric -
How I find my iphone from my imac off. hvordan jeg finder min iphone fra min imac af?
hej jeg står og mangler hjælp til hvordan jeg finder min iphone fra min imac af?
hello I'm standing and need help with how I find my iphone from my imac off?Import photos and videos from your iPhone, iPad, or iPod touch to your Mac or Windows PC - Apple Support
-
How to find max(time) from table using group by
how to find max(time) from table using group by
select var max(time)
from table
into (var1, time1)
where .....
group by var.
it is fetching record which is top in table.
if u can help?
regards.No this will fetch the maximum time from teh table.
select var max(time)
from table xxxx
into (var1, time1)
where .....
group by var.
Refer this code
TABLES SBOOK.
DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
DATA: CONNID LIKE SBOOK-CONNID.
SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
INTO (CONNID, COUNT, SUM, AVG)
FROM SBOOK
WHERE
CARRID = 'LH ' AND
FLDATE = '19950228'
GROUP BY CONNID.
WRITE: / CONNID, COUNT, SUM, AVG.
ENDSELECT. -
How to find lost files from Iphone without back up
How to find lost files from iPhone without back up?
If you don't have a back up, there's no where to restore them from.
-
How to save the string from JTextFied to database?
can i know how to save the data from JTextFied to databse. Is it using update?
The most straightforward way would be something like:
String myKey=myKeyField.getText();
String foo=fooField.getText();
String sql="update mytable set foo='"+foo+"' where mykey='"+myKey+"'";
connection.createStatement().executeUpdate(sql);
This example assumes that the input fields cannot possibly contain quotes or the string won't be built correctly. Which by the way brings up a question I'd be interested in hearing others answer: What do you do about this? Sometimes I use PreparedStatement which handles that problem, other times I write my own little function to escape the string properly.
You can also read the record into a ResultSet and use ResultSet.update(). I'm mostly using mySql and I found that in mySql ResultSet.update just creates a SQL update statement like I did above and executes it, so the only real advantage would be if you find the syntax more convenient. Perhaps other database drivers do something different that would give other pros and cons.
Maybe you are looking for
-
IOS 5.0 - IPad v1 - Frequent Crashes
I own three IPad 32G 3G devices. Two have been updated to IOS 5.0. Both devices are experiencing frequent lockups followed by reboots. The lock ups are usually during videos and are associated with an odd sound shortly before reboot. I have yet to be
-
Key Figure format in Years and Months..
Hi, Is there any Key figure similar to 0SRVCLENKYF (Length of Service (in Years)) part of Headcount and Personnel Actions, which should give me value in Years and Months..? Thanks in Advance, Thanks, Madhu.
-
Hi, I have the iphone 4s and just bought an ebook for ibook, trouble is the font is so tiny I can't read it and the font sizer is not working? Please help!
-
When we go for lsmw apart from call transaction and session method in bdc?
Hi Experts,
-
Similar monitors in different targets
Hi, have a doubt For example, when I scope Monitors to below targets, 1. Logical disk (Server) 2. Windows server 2003 Logical Disk 3. Windows server 2008 Logical Disk I couldn't see any unit monitors in 1st one i.e. Logical disk (server), but in 2nd