Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL

Status
Not open for further replies.

NotSQL

Technical User
May 17, 2005
205
GB
Hi Guys,

I've been given a task to rewirte a bit of SQL and was wondering if you could help me out. The bit of sql below takesa while to run so any help would be greatful.


select NET_AMOUNT,
UNIT_AMOUNT,
QUANTITY,
to_Char(PRO_ID) as ProID,
to_Char(PER_ID) as PerID,
to_Char(MEM_ID) as MEM_ID
from INVOICE_LINES
where exists
(select 1
from calendar_periods cap
where cap.id = cap_id
and year_number > = to_number(to_char(sysdate,'YYYY')) - 2)
 
Are you sure this is a SQL Server?
There is NO to_number and to_char functions in T-SQL.


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Ahh Sorry, no its Oracle..

Ill repost it in a oracle forum
 
Code:
select I.NET_AMOUNT,I.UNIT_AMOUNT,I.QUANTITY,to_Char(I.PRO_ID) as ProID,to_Char(I.PER_ID) as PerID,to_Char(I.MEM_ID) as MEM_ID
from INVOICE_LINES I
inner join calendar_periods cap ON cap.id = I.cap_id  
where cap.year_number > = to_number(to_char(sysdate,'YYYY')) - 2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top