Hey kids, got a problem. Here's the code: - Rev.techCompany CASE WHEN techCompany LIKE 'North_IR' THEN 'NorthIR'
-
WHEN techCompany LIKE 'South_IR' THEN 'SouthIR'
-
WHEN techCompany LIKE 'East_IR' THEN 'EastIR'
-
WHEN techCompany LIKE 'North_[^IR]' THEN 'NorthContractor'
-
WHEN techCompany LIKE 'South_[^IR]' THEN 'SouthContractor'
-
WHEN techCompany LIKE 'East_[^IR]' THEN 'EastContractor' END AS Region From xxx.reviews AS Rev
-
GROUP BY Region
What I am trying to accomplish w/ the above code is separate each techCompany into columns of region. The techCompany value will have region as part of the value. (i.e. North Company Name IR, or North Company Name). I am getting an error: - Msg 156, Level 15, State 1, Line 1
-
Incorrect syntax near the keyword 'CASE'
-
Msg 156, Level 15, State 1, Line 16
-
Incorrect syntax near the keyword 'AS'.
-
Msg 156, Level 15, State 1, Line 22
-
Incorrect syntax near the keyword 'AS'.
-
Msg 156, Level 15, State 1, Line 28
-
Incorrect syntax near the keyword 'AS'.
-
Msg 156, Level 15, State 1, Line 34
-
Incorrect syntax near the keyword 'AS'
Thank you for any advice.
2 5234 ck9663 2,878
Recognized Expert Specialist
Hey kids, got a problem. Here's the code: - Rev.techCompany CASE WHEN techCompany LIKE 'North_IR' THEN 'NorthIR'
-
WHEN techCompany LIKE 'South_IR' THEN 'SouthIR'
-
WHEN techCompany LIKE 'East_IR' THEN 'EastIR'
-
WHEN techCompany LIKE 'North_[^IR]' THEN 'NorthContractor'
-
WHEN techCompany LIKE 'South_[^IR]' THEN 'SouthContractor'
-
WHEN techCompany LIKE 'East_[^IR]' THEN 'EastContractor' END AS Region From xxx.reviews AS Rev
-
GROUP BY Region
What I am trying to accomplish w/ the above code is separate each techCompany into columns of region. The techCompany value will have region as part of the value. (i.e. North Company Name IR, or North Company Name). I am getting an error: - Msg 156, Level 15, State 1, Line 1
-
Incorrect syntax near the keyword 'CASE'
-
Msg 156, Level 15, State 1, Line 16
-
Incorrect syntax near the keyword 'AS'.
-
Msg 156, Level 15, State 1, Line 22
-
Incorrect syntax near the keyword 'AS'.
-
Msg 156, Level 15, State 1, Line 28
-
Incorrect syntax near the keyword 'AS'.
-
Msg 156, Level 15, State 1, Line 34
-
Incorrect syntax near the keyword 'AS'
Thank you for any advice.
have you tried:
1. i hope there's a SELECT keyword in the beginning of your query.
2. put a comma after "Rev.techCompan y"
3. you have 2 fields on your SELECT fieldlist, but only 1 in GROUP BY. as a general rule, all non-aggregate function on your SELECT list must be included in your GROUP BY.
4.i don't (read: am not sure) think sql-server allow a GROUP BY on a generated field. you might need to duplicate the entire CASE...WHEN.. on your GROUP BY...
happy coding
-- CK
have you tried:
1. i hope there's a SELECT keyword in the beginning of your query.
2. put a comma after "Rev.techCompan y"
3. you have 2 fields on your SELECT fieldlist, but only 1 in GROUP BY. as a general rule, all non-aggregate function on your SELECT list must be included in your GROUP BY.
4.i don't (read: am not sure) think sql-server allow a GROUP BY on a generated field. you might need to duplicate the entire CASE...WHEN.. on your GROUP BY...
happy coding
-- CK
Thank you for the reply. It seems to be working so far. I have to build some fill DB w/ dummy data to fully test but I stopped getting error codes. Thank you again.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: blue |
last post by:
I'm trying to order a varchar column first numerically, and second
alphanumerically using the following SQL:
SELECT distinct doc_number
FROM doc_line
WHERE product_id = 'WD' AND doc_type = 'O'
ORDER BY CASE WHEN IsNumeric(doc_number) = 1
THEN CONVERT(FLOAT, doc_number)
ELSE 999999999
END,
|
by: Tcs |
last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't
loaded it yet. I'm still using MS Access. And no, I don't believe this is an
Access question. (But who knows? I COULD be wrong... :) I've tried the
access group...twice...and all I get is "Access doesn't like ".", which I know,
or that my query names are too long, as there's a limit to the length of the SQL
statement(s). But this works when I don't try to...
|
by: MLH |
last post by:
Suppose the following...
Dim A as Date
A=#7/24/2005#
I wish to compare value of A against 2 other values:
1) 8/1/2005
2) 9/1/2005
Which is better and why...
First:
|
by: Lauren Quantrell |
last post by:
Is there any speed/resource advantage/disadvantage in using
Select Case x
Case 1
Case 2
etc. many more cases...
End Select
VS.
|
by: Rob Meade |
last post by:
Ok - I *think* this is only different in .net 2.0 - as I've not had any
problems in the past, but then maybe I've not tried it...
I have a value being read from an xml file where the value maybe a word or a
number, ie...
Low or 1
Medium or 2
High or 3
| |
by: |
last post by:
Hello,
This is gonna sound real daft, but how do I test a Select Case statement for
variants of a theme?
Here's a snippet of my code...
Select Case sUsr
Case "Guest", "TsInternetUser", "krbtgt", "quality7"
' don't show
|
by: kd |
last post by:
Hi All,
Does 'Select Case' construct perform logical short-circuiting like the
'OrElse' opeartor or does it function like the 'Or' operator?
For Example:
Dim sTeststr as String
sTeststr = "ABC"
Select Case sTeststr
Case "ABC","DEF","GHI"
|
by: aa |
last post by:
Code like this
=======================
Select case q
Case "a"
Dim arr(5)
Case "b"
Dim arr(2)
end select
=====================
returns an error saying variable arr redefined.
|
by: beacon |
last post by:
Hello to everybody,
I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know), but each answer is given a different point value for each question.
For instance, question 1 might ask "Do you like candy?" and if you answer Yes you will get +1, No will earn you -1, and Don't know will net you zero points. The next question might...
|
by: tjc0ol |
last post by:
Hi guys,
I'm a newbie in php and I got error in my index.php which is:
1054 - Unknown column 'p.products_id' in 'on clause'
select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |