I'm trying to export the latest records from SQL Server 2005 database once weekly. This is my table:
agent_name date ID
ALEX 2015-05-25 13
ALEX 2015-05-22 13
ALICE 2015-05-24 10
ALICE 2015-05-26 10
How to create output table should like this:
agent_name date ID
ALEX 2015-05-25 13
ALICE 2015-05-26 10
My sql script:
SELECT a.agent_name,
a.date,
a.ID
FROM Payment a
INNER JOIN agentmaster b ON a.ID = b.ID2
WHERE b.agent ='Y'
AND a.date >= DATEADD(day, -7, GETDATE())
Aucun commentaire:
Enregistrer un commentaire