CASE - WHEN WITH
I This operator discovered that I had not yet met:
select name, type
CASE WHEN 1 THEN 'private customer'
WHEN 2 THEN 'public customer'
WHEN 3 THEN 'reseller'
ELSE 'unknown' END
from
Thursday, March 13, 2008
Wedding Seating Chart Project
in SQL in SQL How
often in a SQL query you need a result to be used for various operations. Instead of always
recalculate all the results whenever you can use this form:
WITH TempTable (id, name) as
(
select userid, username from users WHERE
Affilizazione < @data
)
select * from TempTable.
....
....
This function is very powerful because it reduces the processing time of the script.
Remember that WITH or GO should be preceded by a semicolon before WITH (';') if there is another query.
often in a SQL query you need a result to be used for various operations. Instead of always
recalculate all the results whenever you can use this form:
WITH TempTable (id, name) as
(
select userid, username from users WHERE
Affilizazione < @data
)
select * from TempTable.
....
....
This function is very powerful because it reduces the processing time of the script.
Remember that WITH or GO should be preceded by a semicolon before WITH (';') if there is another query.
Subscribe to:
Posts (Atom)