MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

query for no. of rows with a column value ending with x'00'

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
mayuri
Beginner


Joined: 26 Aug 2006
Posts: 17
Topics: 4

PostPosted: Sat Mar 24, 2007 7:48 am    Post subject: query for no. of rows with a column value ending with x'00' Reply with quote

hi all,

A DB2 table column has a value like ABCD QWER.
when i extracted this value and wrote into a file it was written as ABCD QWER only.

The . is actually x'00' and i found this by doing HEX ON in the SPUFI by executing a query which gives me this row.

Now i want to find out how many rows are present in the table where the value in this column ends with x'00'.

select count(column) from table where column like '%.' will not work because '.' is x'4B'.

can anyone help me with the query please.

Thanks in advance

Mayuri
[/quote]
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Sat Mar 24, 2007 8:37 am    Post subject: Reply with quote

try select count(column) where HEX(RIGHT(column,1)) = x'00'
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Mar 26, 2007 8:00 am    Post subject: Reply with quote

mayuri,

You can specify the search string in hex along with the %(x'6c') sign in hex. Try this

Code:

SELECT COUNT(column)       
  FROM Table                 
 WHERE column LIKE X'6C00'
;           


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mayuri
Beginner


Joined: 26 Aug 2006
Posts: 17
Topics: 4

PostPosted: Tue Mar 27, 2007 12:19 am    Post subject: Reply with quote

hi all,
i got it with the following query:
select count(column) from table where RIGHT(column,1) = X'00'

also the query given by Kolusu.

Thanks dbzTHEdinosauer and Kolusu for your inputs.

Regards
Mayuri
Back to top
View user's profile Send private message
mayuri
Beginner


Joined: 26 Aug 2006
Posts: 17
Topics: 4

PostPosted: Mon Apr 09, 2007 9:38 am    Post subject: Reply with quote

hi all
i have got one more query on LIKE search. i have few rows where " is present in one of the column value.
i have queried as follows
select count(*) from table where column like '%"%';

the resutl was 22

but when i queried using the following query
select count(*) from table where column like X'7F';

i'm getting result as 142

can anybody tell me the problem. is the second query right?

Thanks in advance

Regards
Mayuri A
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Apr 09, 2007 12:38 pm    Post subject: Reply with quote

only thing I can think of is that the double-quote is possibly being interpreted as an escape, thus the first query returns the number of columns with a percent sign and the second query returns the number of columns with a double-quote as the first char. but, since I don't have a db2 immediately available, I can't play. so, these are only guesses.

have fun, would like to know the answer.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Tue Apr 10, 2007 1:08 am    Post subject: Reply with quote

Your second query gives the count where the column value is ". First query gives the count even if you have '.''.' as the value.

So, your second query should be the correct one.


Last edited by vkphani on Tue Apr 10, 2007 5:48 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Apr 10, 2007 5:36 am    Post subject: Reply with quote

mayuri,

since we are only talking about 164 items, did you select, display and interrogate the returned columns? you could then answer the question yourself and provide an answer to us. thx
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
mayuri
Beginner


Joined: 26 Aug 2006
Posts: 17
Topics: 4

PostPosted: Wed Apr 11, 2007 5:51 am    Post subject: Reply with quote

hi all,

thanks for your responses. firstly i would like to apologize for the reason that the output of my second query is not 142 but zero.

anyways the first query is the correct one.

Regards
Mayuri A
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group