Last active
August 29, 2015 14:18
-
-
Save phpdave/4438a76362d7e5d68c65 to your computer and use it in GitHub Desktop.
get coulmns and record count in 1 SQL query
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 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