How do I put a date function in a Complex Query that is made by joins?
My Qu开发者_如何学编程ery is:
SELECT
c.aCustID AS 'Contact ID',
o.[FldDate22526] AS 'Opportunity Date',
o.[FldNumeric22532] AS 'Opportunity Allotted to',
n.tOpportunityname AS 'Opportunity Name',
p.[FldString22540] AS 'Opportunity Phone',
p.[FldString22539] AS 'Opportunity Address',
r.[FldString22543] AS 'Opportunity Remerks (Customer Care)',
p.[FldString22538] AS 'Opportunity Remerks (Sales)',
o.[FldNumeric22536] AS 'Opportunity Status (5 Day)'
FROM
tblCustomer AS c
JOIN [tblObjectType3_3] as o
ON c.aCustID = o.nID
JOIN tblOpportunity AS n
ON o.nID = n.aOpportunityID
JOIN [tblObjectType3_11] AS p
ON o.nID= p.nID
JOIN [tblObjectType3_2] AS r
ON p.nID = r.nID
I'm going to guess that all you want to do is limit your results to those in a date range. For example:
SELECT ...
FROM ...
WHERE o.[FldDate22526] > sysdate
or perhaps
SELECT ...
FROM ...
WHERE o.[FldDate22526] BETWEEN now() and now()-7
Not sure which DB, so not sure which date syntax to use.
精彩评论