Wednesday, March 21, 2012

DB2 - SQL - First few SQLS

A) Record to get data in a range of row numbers


SELECT * FROM
(SELECT name, rownumber() over
(order by name)
AS rn FROM address)
AS tr WHERE rn between 10 and 20

------------------------------------------------------

B) Using SELECT statement to UPDATE records in SQL

You can use SELECT statement to update records through UPDATE statement.
In the SET Clause use the SELECT statement along with desired filters to
update the records.

UPDATE tblDestination
SET tblDestination.col=value
WHERE EXISTS (
SELECT col2.value
FROM tblSource
WHERE tblSource.join_col=tblDestination.join_col
AND tblSource.constraint=value)

---------------------------------------------------------

C) Find code page/ encoding of tables


SELECT ENCODING_SCHEME
FROM SYSIBM.SYSTABLES
WHERE NAME = 'IMPADMIN.ATV'

No comments:

Post a Comment