Fordraiders
asked on
tranalate sql server sql to Access sql
I need the following query in Access sql ?
SELECT t_dispensing_metrics_heade r.AutoID, t_dispensing_metrics_heade r.Legal_Na me,
DateDiff(dd,[Disp MA_End_Date],[Corp_MA_end_ Date]) AS Difference,
DateDiff(dd,[Disp MA_End_Date],GETDATE()) as 'Soon',
t_dispensing_metrics_heade r.[Disp MA_End_Date],
t_dispensing_metrics_heade r.Corp_MA_ End_Date
FROM t_dispensing_metrics_heade r
where [Corp_MA_end_Date] is not null
and DateDiff(dd,[Disp MA_End_Date],[Corp_MA_end_ Date]) > 0
and DateDiff(dd,[Disp MA_End_Date],[Corp_MA_end_ Date]) <= 90
and DateDiff(dd,[Disp MA_End_Date],GETDATE()) >-90
order by 4
Thanks
fordraiders
SELECT t_dispensing_metrics_heade
DateDiff(dd,[Disp MA_End_Date],[Corp_MA_end_
DateDiff(dd,[Disp MA_End_Date],GETDATE()) as 'Soon',
t_dispensing_metrics_heade
t_dispensing_metrics_heade
FROM t_dispensing_metrics_heade
where [Corp_MA_end_Date] is not null
and DateDiff(dd,[Disp MA_End_Date],[Corp_MA_end_
and DateDiff(dd,[Disp MA_End_Date],[Corp_MA_end_
and DateDiff(dd,[Disp MA_End_Date],GETDATE()) >-90
order by 4
Thanks
fordraiders
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<Order By 4>
Rey,
Thanks for that. After 20+ years using Access, I never knew you could do that. Only problem with that is that you never know when someone might change the sequence of the fields in the query.
Rey,
Thanks for that. After 20+ years using Access, I never knew you could do that. Only problem with that is that you never know when someone might change the sequence of the fields in the query.
Interesting.
I never knew that was possible.
It, however, does NOT seem to be recommended
http://blog.sqlauthority.com/2010/12/27/sql-server-order-by-columnname-vs-order-by-columnnumber/
http://www.justskins.com/forums/sql-is-it-possible-46695.html
http://www.connectsql.com/2010/12/sql-server-order-by-column-name-or.html
On the other hand, that could be very handy where the order by is a computed column with an alias, as the SQL rarely likes the alias. But there are gotchas, too
http://bradsruminations.blogspot.ca/2010/01/trolls-puzzle-sql-fable.html
Still, good to know
I never knew that was possible.
It, however, does NOT seem to be recommended
http://blog.sqlauthority.com/2010/12/27/sql-server-order-by-columnname-vs-order-by-columnnumber/
http://www.justskins.com/forums/sql-is-it-possible-46695.html
http://www.connectsql.com/2010/12/sql-server-order-by-column-name-or.html
On the other hand, that could be very handy where the order by is a computed column with an alias, as the SQL rarely likes the alias. But there are gotchas, too
http://bradsruminations.blogspot.ca/2010/01/trolls-puzzle-sql-fable.html
Still, good to know
Hi,
you should also be careful in translating "GetDate()" with "Date()". In SQL Server, "GetDate()" is the same as "Now()" in VBA, which means, a date AND time value. That can make a difference in some queries...;-)
Cheers,
Christian
you should also be careful in translating "GetDate()" with "Date()". In SQL Server, "GetDate()" is the same as "Now()" in VBA, which means, a date AND time value. That can make a difference in some queries...;-)
Cheers,
Christian
good catch, Christian! I so rarely use GetDate() in SQL Server that I failed to pickup on that.
Is it just my perception, or have you been conspicuously quiet in EE lately?
Dale
Is it just my perception, or have you been conspicuously quiet in EE lately?
Dale
Hi Dale,
yes, you're right, I'm currently really busy because I'm in the hot phase before a release date of my current project at my employer, not really much time for private things...
Cheers,
Christian
yes, you're right, I'm currently really busy because I'm in the hot phase before a release date of my current project at my employer, not really much time for private things...
Cheers,
Christian
ASKER
Thanks To All..
also work in access and can be translated as
ORDER BY DateDiff(dd,[Disp MA_End_Date],[Corp_MA_end_
which is the 4th column in the query