Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Grabbing current records that have a start date and end date

$
0
0

I want to grab only the current record, preferable in a select sub-query, I try to avoid temp tables.

SELECT DISTINCT

(

LTRIM(RTRIM(SVCCOD)))assvccod,

typcod,

CONVERT(CHAR(6),expdat,112)asEXPDAT,

CONVERT(CHAR(6),effdat,112)asEFFDAT

FROMservcodd

whereLEN(LTRIM(RTRIM(SVCCOD)))=5

OUPTUT (THIS IS ONLY A SAMLE OF THE QUERY ABOVE)

svccodtypcodEXPDATEFFDAT
11008CP999912201501
J9020HX999912201301
K0900HX999912201307
MS065DG999912201310
Q0090HX999912201307
27557CP999912201501
X0224CU201209201209
X5642CU201101201101
X0261DG999912201209
88304RC198501198501


Viewing all articles
Browse latest Browse all 7129

Trending Articles



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