August 3, 2009 at 9:55 am
The following select statement returns records where there are no costs in any of the columns. I want to exclude those records. I have tried setting this up several ways with no luck. Any ideas? Any help will be appreciated.
SELECT ID, UNIT_LABOR_COST, UNIT_BURDEN_COST, UNIT_SERVICE_COST
FROM PART
WHERE PURCHASED = 'Y' AND FABRICATED = 'N'
August 3, 2009 at 9:57 am
it may be an issue with Nulls but to avoid guess work
can you post your table structure and some sample data?
August 3, 2009 at 10:06 am
Nulls are not allowed on any of the columns I am working with in this script.
Sample:
ID UNIT_LABOR UNIT_BURDEN UNIT_SERVICE PURCHASED FABRICATED
123456-1 0.00 0.00 0.00 Y N
I want to exlude records, such as the example, where there are no costs in labor, burden, and service.
August 3, 2009 at 10:26 am
Like this?
SELECT ID, UNIT_LABOR_COST, UNIT_BURDEN_COST, UNIT_SERVICE_COST
FROM PART
WHERE PURCHASED = 'Y' AND FABRICATED = 'N'
AND (UNIT_LABOR_COST 0.00 AND UNIT_BURDEN_COST 0.00 AND UNIT_SERVICE_COST 0.00)
- Jeff
August 3, 2009 at 10:36 am
Please review the article I link to in my signature to learn how to post your question and get better, faster answers.
To answer your question:
SELECT Id
,Unit_Labor_Cost
,Unit_Burden_Cost
,Unit_Service_Cost
FROM dbo.Part
WHERE Purchased = 'Y'
AND Fabricated = 'N'
AND (Unit_Labor_Cost> 0.00
OR Unit_Burden_Cost> 0.00
OR Unit_Service_Cost> 0.00);
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 3, 2009 at 11:49 am
That worked! I appreciate the help. I also read the forum etiquette document. How do I get my code to a window of its own like you two did? Any help will be appreciated.
August 3, 2009 at 1:04 pm
bpowers (8/3/2009)
That worked! I appreciate the help. I also read the forum etiquette document. How do I get my code to a window of its own like you two did? Any help will be appreciated.
I type in the code block myself, others click on the IFCode button and select. When typing in, it is simple:
[ code ] -- remove the spaces
SELECT * FROM MyTable;
[ /code ] -- remove the spaces
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 3, 2009 at 1:30 pm
I appreciate it very much.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply