x404.co.uk
http://www.x404.co.uk/forum/

SQL Select not working
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=12060
Page 1 of 1

Author:  rykard [ Thu Jan 13, 2011 9:19 am ]
Post subject:  SQL Select not working

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 <> '*')

Author:  rykard [ Thu Jan 13, 2011 10:21 am ]
Post subject:  Re: SQL Select not working

sorted now..

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/