Solved

SQL - Filtered on QTY field only in a View

Posted on 2012-03-28
7
371 Views
Last Modified: 2012-03-28
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
Comment
Question by:eleale
  • 4
  • 2
7 Comments
 
LVL 13

Expert Comment

by:AielloJ
ID: 37777831
eleale:

Can you post your data model?

Regards,

AielloJ
0
 

Author Comment

by:eleale
ID: 37777869
AielloJ:

Is this what you need?  See attached.

Thanks.
EXPERTS-SQL.docx
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37777917
SOmething like

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

mlmcc
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:eleale
ID: 37777928
Hi Mlmcc:

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

Thanks.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 37777942
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
 

Author Comment

by:eleale
ID: 37777947
I will give it a try - Thank you.
0
 

Author Closing Comment

by:eleale
ID: 37778469
Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now