Reply to topic  [ 2 posts ] 
SQL Select not working 
Author Message
Occasionally has a life

Joined: Sat Nov 28, 2009 5:28 pm
Posts: 228
Reply with quote
Hi,
I am trying to write a bit of sql to enable me to populate a temp table. Within this query I need to pull back a min and max invoice number from another table. I am feeling a little under the weather and can't seem to get it right, I have copied what I have done so far below... any pointers would be greatly appreciated.

select T93.Employer_ref,T41.Calendar_Year,T41.Monthly_Period,T93.Current_Tax_Year,T93.Current_Pay_Period,1,2,'O',
'T',

select min(t170a.invoice_number)
from invoice_header T170a
where T170a.Employer_Ref = T93.Employer_Ref
and T170a.Tax_Year = T93.Current_Tax_Year
and T170a.Tax_Period = T93.Current_Pay_Period,

'T',
--min(t313.Credit_note_number),max(t313.credit_note_number),
'T' from Employer_reference T93

inner join ER_Period_Details T41
on T41.Employer_Ref = T93.Employer_ref and T93.Current_Tax_Year = T41.Tax_Year and T93.Current_Pay_Period = T41.Tax_Period
inner join Invoice_Header T170
on T170.Employer_Ref = T93.Employer_Ref and T170.Tax_Year = T93.Current_Tax_Year and T170.Tax_Period = T93.Current_Pay_Period
inner join Credit_Note_Header T313
on T313.Employer_Ref = T93.Employer_Ref and T313.Tax_Year = T93.Current_Tax_Year and T313.Tax_Period = T93.Current_Pay_Period
where T93.Employer_Ref in (Select T128.Employer_Ref from Valid_employers T128 where Operator_Ref = 'DEMO' and Employer_Ref <> '*')

_________________
cheers
Rich

A Vision of a Champion is someone who is bent over, drenched with sweat, at the point of exhaustion, when no one else is watching


Thu Jan 13, 2011 9:19 am
Profile
Occasionally has a life

Joined: Sat Nov 28, 2009 5:28 pm
Posts: 228
Reply with quote
sorted now..

_________________
cheers
Rich

A Vision of a Champion is someone who is bent over, drenched with sweat, at the point of exhaustion, when no one else is watching


Thu Jan 13, 2011 10:21 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.