how to apply conditions in sql query code example

Example 1: variables in select statement in sql server

USE AdventureWorks2014;
GO
DECLARE @MyVariable int;
SET @MyVariable = 1;
-- Terminate the batch by using the GO keyword.
GO 
-- @MyVariable has gone out of scope and no longer exists.

-- This SELECT statement generates a syntax error because it is
-- no longer legal to reference @MyVariable.
SELECT BusinessEntityID, NationalIDNumber, JobTitle
FROM HumanResources.Employee
WHERE BusinessEntityID = @MyVariable;

Example 2: Apply functions to results of SQL queries.

# Apply functions to results of SQL queries.

results = spark.sql(
  "SELECT * FROM people")
names = results.map(lambda p: p.name)