合并多个 Select 语句
Combining Multiple Select Statements
我正在寻找 select 来自 2 个表的多行数据,我还需要 select 大小写;例如:
select h.enquiry_id, h.hire_type, h.dry_drop, h.mobile_timestamp, s.signature_time, s.printed_name,
Convert (varchar,(s.signature_time-h.mobile_timestamp),108) as difference
from hire h
join signature s on s.hire_id = h.id
where s.typ = 0
select case
when dry_drop = 0 then 'no'
when dry_drop = 1 then 'yes'
end as dry_drop
from hire
select case
when collection = 0 then 'no'
when collection = 1 then 'yes'
end as collection
from hire
我需要知道如何将这三个 select 语句合并为一个,任何帮助将不胜感激
你可以直接这样使用:
SELECT h.enquiry_id
,h.hire_type
,h.dry_drop
,h.mobile_timestamp
,s.signature_time
,s.printed_name
,Convert(VARCHAR, (s.signature_time - h.mobile_timestamp), 108) AS difference
,CASE
WHEN dry_drop = 0
THEN 'no'
WHEN dry_drop = 1
THEN 'yes'
END AS dry_drop_Case
,CASE
WHEN COLLECTION = 0
THEN 'no'
WHEN COLLECTION = 1
THEN 'yes'
END AS collection_Case
FROM hire h
INNER JOIN signature s ON s.hire_id = h.id
WHERE s.typ = 0
希望这对您有所帮助...!!!
我正在寻找 select 来自 2 个表的多行数据,我还需要 select 大小写;例如:
select h.enquiry_id, h.hire_type, h.dry_drop, h.mobile_timestamp, s.signature_time, s.printed_name,
Convert (varchar,(s.signature_time-h.mobile_timestamp),108) as difference
from hire h
join signature s on s.hire_id = h.id
where s.typ = 0
select case
when dry_drop = 0 then 'no'
when dry_drop = 1 then 'yes'
end as dry_drop
from hire
select case
when collection = 0 then 'no'
when collection = 1 then 'yes'
end as collection
from hire
我需要知道如何将这三个 select 语句合并为一个,任何帮助将不胜感激
你可以直接这样使用:
SELECT h.enquiry_id
,h.hire_type
,h.dry_drop
,h.mobile_timestamp
,s.signature_time
,s.printed_name
,Convert(VARCHAR, (s.signature_time - h.mobile_timestamp), 108) AS difference
,CASE
WHEN dry_drop = 0
THEN 'no'
WHEN dry_drop = 1
THEN 'yes'
END AS dry_drop_Case
,CASE
WHEN COLLECTION = 0
THEN 'no'
WHEN COLLECTION = 1
THEN 'yes'
END AS collection_Case
FROM hire h
INNER JOIN signature s ON s.hire_id = h.id
WHERE s.typ = 0
希望这对您有所帮助...!!!