SQL过滤重复项问题
SELECT DBW.ID AS ID,
TD.ID AS DRIVER_ID,
convert(varchar(10),DBW.START_VALID_TIME,121) as START_VALID_TIME,
DBW.BASIC_WAGE AS BASIC_WAGE,
DBW.IS_VALID AS IS_VALID,
TD.WORK_CARDNO,
TD.DRIVER_NAME
FROM TRUCK_DRIVER TD LEFT JOIN
DRIVER_BASIC_WAGE DBW ON (DBW.DRIVER_ID=TD.ID)
我想做到DRIVER_ID 去掉重复项 也就是DRIVER_ID相同的情况下只显示一项
怎么改SQL
------解决方案--------------------
SELECT DBW.ID AS ID,TD.ID AS DRIVER_ID,convert(varchar(10),DBW.START_VALID_TIME,121) as START_VALID_TIME,DBW.BASIC_WAGE AS BASIC_WAGE,DBW.IS_VALID AS IS_VALID,
TD.WORK_CARDNO,
TD.DRIVER_NAME
FROM TRUCK_DRIVER TD LEFT JOIN
DRIVER_BASIC_WAGE DBW ON (DBW.DRIVER_ID=TD.ID)
where DRIVER_ID in (select distinct TD.ID From TRUCK_DRIVER)
union
SELECT DBW.ID AS ID,TD.ID AS DRIVER_ID,convert(varchar(10),DBW.START_VALID_TIME,121) as START_VALID_TIME,DBW.BASIC_WAGE AS BASIC_WAGE,DBW.IS_VALID AS IS_VALID,
TD.WORK_CARDNO,
TD.DRIVER_NAME
FROM TRUCK_DRIVER TD LEFT JOIN
DRIVER_BASIC_WAGE DBW ON (DBW.DRIVER_ID=TD.ID)
where DRIVER_ID!=''