當我做出這個選擇時,它顯示所有「車轍」與它的電話號碼,我的問題 是每個「車轍」有近10個電話號碼,我只需要3個電話號碼每個「車轍」,我嘗試使用TOP,但只顯示所有表的前3行,而不是由「車轍」第一行 ,我怎麼可以使用TOP只是爲行「車轍」,而不是在所有的 表每組返回前3行
Select Distinct
t1.rut_cliente as rut_cliente,
t1.nro_fono as numero
--Into #tmp_numeros
From dat_clientes_sucursales_contactos_telefonos t1,dat_rut_clientes t2
where t1.rut_cliente = t2.rut_cliente
and cod_prioridad = 1
這就是我得到這個查詢:
Rut_cliente Nro_fono
60506000-5 2046840
60506000-5 3507935
60506000-5 4106886
60506000-5 5440000
60506000-5 5445000
81698900-0 2373281
81698900-0 3541342
81698900-0 3541438
81698900-0 3541518
81698900-0 3542101
,這就是我想要的:
Rut_cliente Nro_fono
60506000-5 2046840
60506000-5 3507935
60506000-5 4106886
81698900-0 2373281
81698900-0 3541342
81698900-0 3541438
在此先感謝。
對於有用的提示+1並在12秒內擊敗我。 – 2012-07-20 19:53:09
@蒂姆謝謝,讓我們小心一點,不要像投票戒指。 :-) – 2012-07-20 20:03:17