Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Query

$
0
0

Below I have the following query which will show all id_number that have a creation date greater than the last day.  I'm looking to tweak the query as it sits looking back at the last day.  It is possible to have multiple id_number under one customer_code.  How can I rewrite this to show the oldest id_number by creation date if the person has multiple id_number?  Can the prior card be listed first?  If they don't have any then just list the new single id_number.

select id_number, Creation_Date, customer_code from Customer_IDs (NOLOCK)

where
ID_Code = 'PS'
and
creation_date >= DateAdd(DD, -1, GETDATE())


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>