Forked from phpdave/GetColumnsAndNumberOfRows.sql
Last active
August 29, 2015 14:20
-
-
Save chukShirley/e199a07cc6ec393349b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT a.*, b.NumberOfRows | |
FROM MYTABLE a | |
CROSS JOIN (SELECT COUNT(*) AS NumberOfRows FROM MYTABLE) b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT a.*, b.NumberOfRows | |
FROM ( | |
SELECT column1, column2, ROW_NUMBER() OVER (ORDER BY :sortColumn :sortOrder) as ROW_NUMBER | |
FROM MYLIB.MYTABLE | |
WHERE column1='Y' | |
AND column2 LIKE('%MYSTRING%') | |
ORDER BY :sortColumn :sortOrder | |
) a | |
CROSS JOIN ( | |
SELECT COUNT(*) as NumberOfRows | |
FROM MYLIB.MYTABLE | |
WHERE column1='Y' | |
AND column2 LIKE('%MYSTRING%') | |
) b | |
WHERE a.column2 LIKE('%MYSTRING%') AND a.ROW_NUMBER >= 1 AND a.ROW_NUMBER <= 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT a.*, b.NumberOfRows | |
FROM MYLIB.MYTABLE1 a | |
CROSS JOIN | |
(SELECT COUNT(*) AS NumberOfRows FROM MYLIB.MYTABLE2 as c WHERE c.fieldc1=9999) as b | |
WHERE a.fielda1=9999 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment