ตัวอย่าง
การใช้คำสั่ง DISTINCTสำหรับ teble ที่ join กัน (SQL Server Management Studio)
SELECT DISTINCT “TB_SR_01″.”TYPE_CODE”, “TB_SR_01″.”SERVICE_AREA”, “CODE_BOOK”.”CODE_NAME”, “TB_SR_01″.”OPEN_DATE”, “TB_SR_01″.”SUB_TYPE_CODE”, “CODE_BOOK_1″.”CODE_NAME”, “TB_SR_01”.”B_SUB_TYPE_CODE_1″, “CODE_BOOK_2″.”CODE_NAME”
FROM ((“DB”.”dbo”.”TB_SR_01″ “TB_SR_01”
LEFT OUTER JOIN “DB”.”dbo”.”CODE_BOOK” “CODE_BOOK” ON “TB_SR_01″.”TYPE_CODE”=”CODE_BOOK”.”CODE_ID”)
LEFT OUTER JOIN “DB”.”dbo”.”CODE_BOOK” “CODE_BOOK_1” ON “TB_SR_01″.”SUB_TYPE_CODE”=”CODE_BOOK_1″.”CODE_ID”)
LEFT OUTER JOIN “DB”.”dbo”.”CODE_BOOK” “CODE_BOOK_2” ON “TB_SR_01″.”B_SUB_TYPE_CODE_1″=”CODE_BOOK_2″.”CODE_ID”
WHERE (“TB_SR_01”.”SERVICE_AREA”=735 OR “TB_SR_01”.”SERVICE_AREA”=736 OR “TB_SR_01”.”SERVICE_AREA”=737 OR “TB_SR_01”.”SERVICE_AREA”=759 OR “TB_SR_01”.”SERVICE_AREA”=761) AND “TB_SR_01”.”OPEN_DATE”=’20080717′