473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

SQL Query with some problems

7
I'm having an issue with this query. I'm basically running a query where i show two fields using two tables. One will give me the amount and the second one will give me the description. However in my "Where" clause i'm filtering that shows the ones that doesn't have '0' as amount. All that is good, but it comes complicate when i have to filter more descriptions if the order has a specific client number, when this happened then i have to take out the amount that's less than '0'. This is what i did but when VB runs it, it tells me that is an incorrect use of Null, but my goal is basically not to show it but i don't know any other way then i just show it as null. Here is my example:
Expand|Select|Wrap|Line Numbers
  1. select
  2. (case when (left(s.client_id,5) = 504 and b.detail_type_cd = 119) then null else b.amount_nr end) Amount,
  3. (case when (left(s.client_id,5) = 504 and b.detail_type_cd = 119) then null else c.detail_type_ds  end) item_desc
  4. from t_order a with(nolock) 
  5. left outer join t_detail b       on a.order_id = b.order_id
  6. left outer join lu_detail_type c on b.order_detail_type_cd = c.detail_type_cd
  7. left outer join t_client_id d    on a.order_id = d.order_id
  8. Where 
  9. IsNull(b.amount_nr, 0) <> 0 
  10. And a.order_id = 100000 
  11.  
Like i said what i need is that if the clien# 504 and the detail type is 119 then the amount_nr > 0 else amount<>0.

Any help will be good. Thanks in advanced.
Mar 9 '09 #1
2 1393
ck9663
2,878 Expert 2GB
Build your query dynamically. If your GUI has a client#, build your where with client# on it. If not, use default (amount <> 0).

-- CK
Mar 10 '09 #2
lrod
7
Thanks CK, I actually was able to fix it by modifying the CASE and adding it the where clause.
Thank you for your input.

LRod
Mar 11 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: dogu | last post by:
Noob alert. Code is below. File is saved as a .php. What I'm trying to do: User uses 'select' box drop down list to pick a value. Value ($site) is derived from a db query. This works fine....
2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
24
by: jason | last post by:
Hi Ray...a while ago you explained an elegant solution to enable me to CREATE and EDIT existing tables and queries inside my online access 2000 database.... could you provide refresher links on...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
2
by: Steve Richfield | last post by:
First, thanks Wayne Morgan, Cost Budde, and Saintor for all the help you've been in getting me through the field of hidden mines in Access. Most of the program now works, so hopefully I am nearing...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
2
by: webhead74 | last post by:
Hi, I'm having intermittent problems with queries from my php script to a postgresql database. I have a form where I can enter a search query - for instance a last name. This leads to a...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
2
by: Coll | last post by:
I have a form and a query. I would like to have some control on the form (check box probably), that when selected will limit the criteria for a field in a query. Here are the details.... When...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.