Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Another way

Author  Topic 

jfxwave
Starting Member

2 Posts

Posted - 2012-12-13 : 13:33:53
I'm working on this and i'm new to SQL and wanted to know if there was a shorter way to write this? Does "MonthReported" have to be written everytime or can i use a ", "?

quote:
SELECT DISTINCT
OperatorID,
RRCID,
LeaseName,
District,
FieldNumber,
YearReported,
MonthReported,
GasWellNumber,
GasProduction
INTO #Gasleases
FROM GasProductionCopy(NOLOCK)
WHERE (YearReported = 2010) AND ( MonthReported = 9 OR MonthReported = 10 OR MonthReported = 11 OR MonthReported = 12)

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2012-12-13 : 13:36:53
[code]SELECT DISTINCT
OperatorID,
RRCID,
LeaseName,
District,
FieldNumber,
YearReported,
MonthReported,
GasWellNumber,
GasProduction
INTO #Gasleases
FROM GasProductionCopy(NOLOCK)
WHERE (YearReported = 2010) AND MonthReported in (9,10,11,12)[/code]
Go to Top of Page

jfxwave
Starting Member

2 Posts

Posted - 2012-12-13 : 13:49:56
Thanks for the fast reply!
I knew it was easy but thats going to save me some time.

Thanks again
Go to Top of Page
   

- Advertisement -