473,785 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Easy case statement that I cant do

1 New Member
Hello All, This is me first Post ..Yesssss

I am new to sql so I hope I explain this correctly:

I used a PATINDEX statement to create a field called UPS_Shipper in my view and a field called UPSCodeShipTo which is renamed from a field I pulled earlier.

What I have been tasked to do it to create a statement that will do the following:
If there is a value in UPS_CodeShipTo (which there always is) then I need to use that value in a new column (UPS_FINAL) UNLESS there is a value in the UPS_Shipper column in which the value would go to the new column and would REPLACE the value set by UPS_CodeShipTo in the new column. Im new to SQL but this is what i have gathered....

I need to use a CASE statement but I have little experience with this, here is the view I am currently working with...

Any help in the right direction would be much appreciated
Antony
Systems Administrator
--------------------------------------------------------------------------------------------
SELECT P21PLAY.dbo.p21 _view_oe_pick_t icket.pick_tick et_no, P21PLAY.dbo.p21 _view_oe_hdr.or der_no, P21PLAY.dbo.p21 _view_oe_hdr.cu stomer_id,
P21PLAY.dbo.p21 _view_oe_hdr.sh ip2_name, P21PLAY.dbo.p21 _view_oe_hdr.sh ip2_add1, P21PLAY.dbo.p21 _view_oe_hdr.sh ip2_add2,
P21PLAY.dbo.p21 _view_oe_hdr.sh ip2_city, P21PLAY.dbo.p21 _view_oe_hdr.sh ip2_state, P21PLAY.dbo.p21 _view_oe_hdr.sh ip2_zip,
P21PLAY.dbo.p21 _view_oe_hdr.po _no, P21PLAY.dbo.p21 _view_oe_pick_t icket.carrier_i d AS Carrier, P21PLAY.dbo.p21 _view_oe_pick_t icket.carrier_i d AS Supplier,
P21PLAY.dbo.p21 _view_oe_hdr.co d_flag, P21PLAY.dbo.p21 _view_oe_hdr.te rms, P21PLAY.dbo.p21 _view_oe_hdr.sh ip2_country,
P21PLAY.dbo.p21 _view_oe_hdr.sh ip_to_phone, P21PLAY.dbo.p21 _view_oe_hdr.de livery_instruct ions,


SUBSTRING(P21PL AY.dbo.p21_view _oe_hdr.deliver y_instructions, PATINDEX('%[^a-z ]%', P21PLAY.dbo.p21 _view_oe_hdr.de livery_instruct ions) + 1, 6) AS UPS_Shipper,

(CASE WHEN charindex('@', [email_address]) > 0 THEN [email_address] ELSE 'email@domain.c om' END) AS alternate_addre ss, 'Y' AS QVN,
'email@domain.c om' AS failureaddress,

P21PLAY.dbo.p21 _view_contacts. email_address, dbo.[Address Table].ups_code AS UPS_CodeShipTo

FROM P21PLAY.dbo.p21 _view_contacts INNER JOIN
dbo.[Address Table] ON P21PLAY.dbo.p21 _view_contacts. address_id = dbo.[Address Table].id RIGHT OUTER JOIN
P21PLAY.dbo.p21 _view_oe_pick_t icket INNER JOIN
P21PLAY.dbo.p21 _view_oe_hdr ON P21PLAY.dbo.p21 _view_oe_pick_t icket.order_no = P21PLAY.dbo.p21 _view_oe_hdr.or der_no ON
P21PLAY.dbo.p21 _view_contacts. id = P21PLAY.dbo.p21 _view_oe_hdr.co ntact_id
WHERE (P21PLAY.dbo.p2 1_view_oe_pick_ ticket.ship_dat e IS NULL)
Nov 17 '07 #1
0 928

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

Similar topics

3
3711
by: Rainer Mohr | last post by:
Hi, I´m having some problems with simplexml_load_file() and cant find any sollution anywhere. Say, we have the following file: ---file.xml--- <UNITS>Metric</UNITS> <UNITS>another</UNITS> --------------
26
14158
by: Joe Stevenson | last post by:
Hi all, I skimmed through the docs for Python, and I did not find anything like a case or switch statement. I assume there is one and that I just missed it. Can someone please point me to the appropriate document, or post an example? I don't relish the idea especially long if-else statements. Joe
6
4702
by: deanfamily11 | last post by:
I've set up a case statement to have my program determine where on the Cartesian plane a point the user enters is located. I keep getting the C2051 error when I compile. Any help? #include <iomanip> #include <iostream> using namespace std;
4
2504
by: google | last post by:
<html> <head> <title>JavaScript Replace</title> <script language="JavaScript1.1" type="text/javascript"> function phils_image_price(input) { //declare variables var output="" var position=0
2
1608
by: Showjumper | last post by:
How can i go about doing case sensitive passwords w/ forms auth, vbnet and asp.net 1.1? I found an msdn mag article that used cast as varbinary in the sql statement but i cant get it to work. Is the sql approach best? What other approaches are there? Ashok
6
1934
by: graeme g | last post by:
hi how would i write the following in switch case statement: if (x < 40) y = 0; else if (x < 65) y = 1; else if (x < 80) y = 2;
1
21689
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case "01" : dWarrExpDateMonth="Jan" : dRetailDateMonth="Jan" case "02" : dWarrExpDateMonth="Feb" : dRetailDateMonth="Feb" End Select
3
1222
by: vegtard | last post by:
by now, you have no doupt replied to many of mine and my buddy (børntard)'s questions about our faulty programming concerning the over-complicated mega-script to design your dungeons and dragons roleplaying character. well, i think i have cracked it. but theres one slight problem i cant seem to get my head wrapped around. i have an IF-statement in my script. well, i have a rediculous ammount actually. but my script skips one of them, and its...
5
1501
mcc
by: mcc | last post by:
I am having a problem with my homework I cant seem to get the redirection with onClick. The script is supposed to have the user insert the name and password and the choose a department from a drop down. The instruction state that we have to use a case statement. Below is the code. I’m new here to this forum so please forgive my messiness in the post. Any help will be greatly appreciated THANKS in advance! I know its choppy and I have changes...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.