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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Need help with a query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 02/28/2013 :  05:36:44  Show Profile  Reply with Quote
i need to write a query from one table but with elements from documents with diferent internal numbers.

how can i relate the two diferent internal numbers of documents on the query?

select bo.orinopat as 'N PAT', as 'Cliente',
bo.nome as 'Nome Cliente',
bo.fref as 'N OBRA',
bo.obrano as 'N FObra',
bo.dataobra as 'Data FObra',
bo.datafecho as 'Dt Fecho FO',
bo.vendnm as 'Comercial',
bo.ecusto as 'Custo FObra',
bo.etotaldeb as 'Valor Venda',
((((bo.etotaldeb-bo.ecusto)*100))/bo.etotaldeb) as 'Margem Percent'
From bo
Where bo.ndos like 32

(Select bo.orinopat as 'N PAT', as 'Cliente',
bo.nome as 'N Cliente',
bo.obrano as 'N Orç',
bo.dataobra as 'Data Orç',
bo.datafecho as 'Dt Fecho Orc',
bo.vendnm as 'Comercial',
bo.datafinal as 'Dt Adj',
bo.etotaldeb as 'Total Venda',
bo.ecusto as 'Custo Previsional',
bo.u_cpag as 'Cond Pag 1',
bo.u_evala as 'Euros Cond Pag 1',
bo.u_cpaga as 'Cond Pag 2',
bo.u_evalb as 'Euros Cond Pag 2'
From bo
Where bo.ndos like 11)


Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/28/2013 :  06:34:59  Show Profile  Reply with Quote
Where bo.ndos IN (32,11,.. other values if any)

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000