This file contains hidden or 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
| -- Show "all months" in results | |
| -- even if there's data missing | |
| -- Define start/end dates for the query | |
| DECLARE @startDate AS DATE = '1/1/2023'; | |
| DECLARE @endDate AS DATE = '12/31/2023'; | |
| -- We'll use this to iterate in the loop |
This file contains hidden or 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
| DROP TABLE IF EXISTS #temp | |
| CREATE TABLE #temp ( | |
| id INT IDENTITY (1,1) | |
| , org VARCHAR(50) | |
| ) | |
| INSERT INTO #temp (org) | |
| SELECT 'aaa' UNION | |
| SELECT 'bbbb' UNION |
This file contains hidden or 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 maxDay | |
| FROM ( | |
| SELECT theYear, theMonth, MAX(theDay) AS maxDay | |
| FROM ( | |
| SELECT YEAR(myDate) AS theYear, MONTH(myDate) AS theMonth, MAX(myDate) AS theDay | |
| FROM myTable | |
| GROUP BY myDate | |
This file contains hidden or 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
| <?php function showPagination($arrPagination) { ?> | |
| <?php | |
| $pageLink = $arrPagination['pageLink']; | |
| $urlVarsWithoutPage = $arrPagination['urlVarsWithoutPage']; | |
| $limit = $arrPagination['limit']; | |
| $totalRowCount = $arrPagination['totalRowCount']; | |
| $page = $arrPagination['page']; |
This file contains hidden or 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
| DROP TABLE IF EXISTS #previous | |
| DROP TABLE IF EXISTS #current | |
| DECLARE @previousDate AS DATE; | |
| SET @previousDate = '9/30/2021'; | |
| DECLARE @currentDate AS DATE; | |
| SET @currentDate = '10/31/2021'; | |
This file contains hidden or 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
| -- New Hires | |
| DECLARE @minDate DATE = (SELECT MIN(ReportDate) FROM dbo.Rosters) | |
| SET @minDate = CAST( DATEADD(month, DATEDIFF(month, 0, @minDate), 0) AS DATE) | |
| --SELECT @minDate | |
| SELECT | |
| tblPrevious.FirstOfPrevMonth, tblPrevious.EmplID, tblPrevious.Name | |
| FROM ( |
This file contains hidden or 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
| -- Attrition | |
| DECLARE @maxDate DATE = (SELECT MAX(ReportDate) FROM dbo.Rosters) | |
| SET @maxDate = CAST( DATEADD(month, DATEDIFF(month, 0, @maxDate), 0) AS DATE) | |
| --SELECT @maxDate | |
| SELECT | |
| tblPrevious.FirstOfMonth, tblPrevious.EmplID, tblPrevious.Name | |
| FROM ( |
This file contains hidden or 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
| <?php | |
| $params = []; | |
| $params[':first_name'] = $first_name; | |
| $sql = "INSERT INTO Users (first_name) VALUES (:first_name)"; | |
| return $db->runSQL($sql, $params); // will return true or display an error | |
| ?> |
This file contains hidden or 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
| <?php | |
| class Database{ | |
| private $host; | |
| private $username; | |
| private $password; | |
| private $database; | |
| private $conn; | |
| public function __construct($host, $username, $password, $database){ |
This file contains hidden or 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
| <?php | |
| $first_name = quote_smart($db1, $_POST['first_name']); | |
| $query = "INSERT INTO Users (`first_name`) VALUES ('$first_name')"; | |
| ?> |