MsSQL

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesMsSQL

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old October 24th, 2012, 03:09 AM
makis_best makis_best is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 makis_best User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 51 sec
Reputation Power: 0
Case statement not working

Hi all

I have this Case statement but seems not working, can anyone help with the script?

Select LItmSale.name,
CASE LItmSale.LinkID
WHEN 001 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.001)
WHEN 002 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.002)
WHEN 003 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.003)
WHEN 004 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.004)
WHEN 005 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.005)
WHEN 006 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.006)
WHEN 008 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.008)
WHEN 016 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.016)
WHEN 017 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.017)
WHEN 018 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.018)
ELSE 0
END as VALUES
from litmsale

Now....
I get no error.
The selects return null values when I run the script.
When I run every select in parenthesis individual the return value (Price) is correct.
If I replace any select with the number 1 then the script runs OK and returns the value 1 correct.
For example "WHEN 001 THEN 1" that works but the select doesn't.
Why that happens?

Please help.
Thank you

Reply With Quote
  #2  
Old January 30th, 2017, 05:14 AM
Rashmi.Padia Rashmi.Padia is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2017
Location: Ahmedabad
Posts: 24 Rashmi.Padia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 8 m 8 sec
Reputation Power: 0
Hi,

You can use this case statement following like this,

Code:
Select LItmSale.name,
(CASE LItmSale.LinkID 
WHEN 001 THEN (SELECT Price FROM ItemPrc WHERE PriceListAA = 39 AND PriceCtgr = 'Team1' AND ServiceID = 100.001) 
.
.
.
 
ELSE 0
END)
from litmsale;


Thanks,
Comments on this post
dishagandhi agrees!

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesMsSQL > Case statement not working


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap