chokka
asked on
SQL - Order by Asc query
SQL 2005 / 2008
This query over here ...
select DateFilled from
(
select patcustid,DaysSupply,DateF illed from vOeOrderHistoryWide
union all
select patcustid,DaysSupply,DateF illed from vOeOrderWide
)as x
where patcustid = 8
Returns Null and Date Field.
When i filter the query with Order By Asc - It returns NULL. Instead of picking the NULL Value, i am looking for first lowest Date Filled.
How to tune the query to fetch the lowest Date Filled !!
This query over here ...
select DateFilled from
(
select patcustid,DaysSupply,DateF
union all
select patcustid,DaysSupply,DateF
)as x
where patcustid = 8
Returns Null and Date Field.
When i filter the query with Order By Asc - It returns NULL. Instead of picking the NULL Value, i am looking for first lowest Date Filled.
How to tune the query to fetch the lowest Date Filled !!
select top 1 DateFilled from
(
select patcustid,DaysSupply,DateFilled from vOeOrderHistoryWide
union all
select patcustid,DaysSupply,DateFilled from vOeOrderWide
)as x
where patcustid = 8
order by DateFilled asc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.