Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

WHERE Clause

$
0
0

Hi,

I have the following code below but the WHERE clause doesn't seem to be doing what I had hoped and wondered if there is something missing or the order is incorrect?

I am still return values where there is a contract_value which I don't want, I only need to see the contract_value that is = 0

I then need to return Invoiced_Total or Total net if it has a value >0

select 
distinct(dbo.Finance.job_number) as job_number,
dbo.Finance.client_name, 
dbo.Finance.Date_in,
dbo.Finance.total_contract, 
dbo.Finance.invoiced_total,
sum(dbo.INCOME.Total_Net) as draft_invoice

from 
dbo.Finance. 
left join dbo.INCOME
on dbo.Finance.job_number = dbo.INCOME.job

where 
dbo.Finance.job_number LIKE '1/%' or dbo.Finance.job_number LIKE '2/%'
and dbo.Finance.total_contract = '0'
and dbo.Finance.invoiced_total > '0'
or dbo.INCOME.Total_Net > '0'

group by 
dbo.Finance.client_name, 
dbo.Finance.job_number,
dbo.Finance.Date_in,
dbo.Finance.total_contract, 
dbo.Finance.invoiced_total



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>