Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

SQL - Filtered on QTY field only in a View

New to using SQL - I created a view and need to add a field for the Quantity Field, I need this field to exclude one product line in my table.  However, I need the Product Line on the entire table but just filtered for the quantity field. Is there a way to do this?  

For example - My QTY field includes Freight.  My $$ fields need to include the Freight $$'s so I can't eliminate the Freight from the entire table I just don't want the QTY field to include the Freight numbers, as it doubles the Qty Amount.  

In Crystal - I would create a formula as:

If {ProductLine} = "FRGT" then 0 else {Qty}

Any help would be great!  Trying to not do this report in Crystal.  

Thank you.

Using MS SQL Management Studio - 2008 R2 - Free version
0
Erin Leale
Asked:
Erin Leale
  • 4
  • 2
1 Solution
 
AielloJCommented:
eleale:

Can you post your data model?

Regards,

AielloJ
0
 
Erin LealeConsultant/ControllerAuthor Commented:
AielloJ:

Is this what you need?  See attached.

Thanks.
EXPERTS-SQL.docx
0
 
mlmccCommented:
SOmething like

Case ProductLine
      "FRGT"  :  Cost
      Others  :  Cost * Qty
End  As ExtendedCost

mlmcc
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Erin LealeConsultant/ControllerAuthor Commented:
Hi Mlmcc:

Where in SQL do you excute a Case Statement? Is it part of the SQL statement?

Thanks.
0
 
mlmccCommented:
It is part of the SELECT

SELECT fields, CASE .... , fields
FROM ....

I don't have a SQL database here so the syntax is from memory.

mlmcc
0
 
Erin LealeConsultant/ControllerAuthor Commented:
I will give it a try - Thank you.
0
 
Erin LealeConsultant/ControllerAuthor Commented:
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now