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
| CREATE FUNCTION dbo.isoweek (@DATE datetime) | |
| RETURNS INT | |
| WITH EXECUTE AS caller | |
| AS | |
| BEGIN | |
| DECLARE @ISOweek INT | |
| SET @ISOweek= datepart(wk,@DATE)+1 | |
| -datepart(wk,CAST(datepart(yy,@DATE) AS CHAR(4))+'0104') |
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
| CREATE TABLE datatype | |
| (fld0 GENERICTYPE, | |
| fld1 CHAR(2), | |
| fld3 NCHAR(1)); |
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 department_id, | |
| Min(salary) | |
| FROM employees | |
| GROUP BY department_id |
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 last_name | |
| FROM employees | |
| WHERE salary > (SELECT salary | |
| FROM employees | |
| WHERE last_name = 'Abel'); |
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 (( ( a - b ) - c )) | |
| FROM t |
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
| CREATE FUNCTION sales.Fn_salesbystore | |
| (@storeid INT) | |
| RETURNS TABLE | |
| AS | |
| RETURN 0; |
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 * | |
| FROM dual | |
| WHERE 1=-1 | |
| AND(1!=2 | |
| OR 2^=3) | |
| AND 3<>4 | |
| AND 4>5; |
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
| vFirstName := 'Roger'; | |
| vLastName := 'Smith'; | |
| vSSN := 999999999; |
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
| DELETE FROM job_history jh | |
| WHERE employee_id = (SELECT employee_id | |
| FROM employee e | |
| WHERE jh.employee_id = e.employee_id | |
| AND start_date = (SELECT Min(start_date) | |
| FROM job_history jh | |
| WHERE jh.employee_id = e.employee_id) | |
| AND 5 > (SELECT Count( * ) | |
| FROM job_history jh | |
| WHERE jh.employee_id = e.employee_id |
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 DISTINCT | |
| p.name AS product, | |
| p.listprice AS 'List Price', | |
| p.discount AS 'discount' | |
| FROM production.product p |