View previous topic :: View next topic
|
Author |
Message |
pdevidas12
New User
Joined: 28 Feb 2010 Posts: 3 Location: Pune
|
|
|
|
HI
WHEN WE HAVE LOW VALUES IN COLUMN SUPPOSE NAME SO HOW I CAN GET ALL THE ROWS WHERE I HAVE THE LOW VALUES. LIKE
SELECT * FROM TABLE WHERE NAME = "PDEVDAS12"
SO WHAT WE HAVE TO GIVE IN NAME TO FIND OUT ALL COLUMN WHERE VALUES ARE "LOW VALUES"
THANKS
PDEVIDAS12IN c |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
first, do not write in capital letters
second, define LOW VALUES |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
that is very poor sql. you should select only those columns that you need.
I will attribute your wording of your question as a language thing.
low-values is a COBOL literal, has nothing to do with db2
you want to select 'what' WHEN NAME = X'0000000000' ?
the literal has to be the same number of characters as the column NAME
if NAME is CHAR(10) the literal has to be x'00000000000000000000'
if NAME is varchar you will need to substring the literal for the length of the column NAME length.
are you sure that all bytes of the column NAME are binary zeroes? |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
pdevidas12 wrote: |
HI
WHEN WE HAVE LOW VALUES IN COLUMN SUPPOSE NAME |
What is the definition of the column in the table? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Is this a person's name rather than a database column name?
What if the value is not x'0000000000. . .' but rather multiple non-printable characters (i.e. x'122334. . .'? A test for "low-values" will be not-equal, but i suspect you would want these identified. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Okay, based on a pure guess, please try this:
Code: |
SELECT NAME FROM TABLE
WHERE LENGTH (NAME) > LENGTH (REPLACE(NAME, X?00?,'') ; |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Anuj,
Why is LENGTH mentioned?
Devidas, if you want help, you have to participate. . . |
|
Back to top |
|
|
pdevidas12
New User
Joined: 28 Feb 2010 Posts: 3 Location: Pune
|
|
|
|
First Sorry to Moderator,,,, Next time onward I will post queries in small letters only.
I have faced this question in interview, It may possible he/she may have confused me with LOW-VALUES of DB2 and COBOL. But if at all there wont be any "LOW VALUES" in DB2?
thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
low-values is a COBOL figurative constants that means binary-zeroes.
and no, it is conceivable to find binary-zeros in char data type columns. |
|
Back to top |
|
|
|