再会。
我有sql查询:
SELECT TOP 20
p.id_price as p_id_price,
p.id_service as p_id_service,
p.name as p_name,
p.name_original as p_name_original,
p.id_producer_country as p_id_producer_country,
p.id_firm as p_id_firm,
f.name as f_name,
f.priority as f_priority,
f.address as f_address,
f.phone as f_phone,
city.name as city_name,
pc.name as pc_name
FROM Price p
left join Firm f on f.id_service = p.id_service AND f.id_city = p.id_city AND f.id_firm = p.id_firm
left join City city on city.id_city = p.id_city left join Producer_country pc on pc.id_producer_country = p.id_producer_country
left join Dogovor d on d.id_service=p.id_service AND d.id_city=p.id_city AND d.id_firm=p.id_firm
WHERE
id_price NOT IN (
SELECT TOP 20 p.id_price
FROM Price p
left join Firm f on f.id_service = p.id_service AND f.id_city = p.id_city AND f.id_firm = p.id_firm
left join City city on city.id_city = p.id_city
left join Producer_country pc on pc.id_producer_country = p.id_producer_country
left join Dogovor d on d.id_service=p.id_service AND d.id_city=p.id_city AND d.id_firm=p.id_firm
WHERE p.id_city='73041' AND p.include='1' AND p.blocked='0' AND f.blocked='0' AND f.dogovor='1'
AND d.end_date >= '20131108 02:37:03'
AND (p.name LIKE '% tes_ %' OR p.name LIKE 'tes_ %' OR p.name LIKE '% _tes_%')
ORDER BY f.priority DESC
)
AND p.id_city='73041'
AND p.include='1'
AND p.blocked='0'
AND f.blocked='0'
AND f.dogovor='1'
AND d.end_date >= '20131108 02:37:03'
AND (p.name LIKE '% tes_ %' OR p.name LIKE 'tes_ %' OR p.name LIKE '% _tes_%')
ORDER BY f.priority DESC
但它查询选择并输出具有相同字段f.name值的多行
请告诉我如何从具有相同字段f.name值的多行中仅选择一行 ?
请告诉我如何在同一个 f.name 中做行号,然后选择第一个数字?