Dear Folks,
I have an query which something looks like this
select ILTRDJ AS YEAR, DATEPART(MONTH,ILTRDJ) AS MONTH,
FMSTR.IMITM AS CODE,FMSTR.IMSRP6_UDC AS DESCRIPTION, FTRANS.ILDCT [Recieved] =
CASE
WHEN (select FTRANS.ILDCT FROM [TP].[dbo].[F4111Selected] FTRANS
WHERE FMSTR.IMITM = FTRANS.ILITM and FTRANS.ILDCT = 'OV')
THEN 'OV'
ELSE 'OTHERS'
END,
[Issued Job] =
CASE
WHEN (select FTRANS.ILDCT FROM [TP].[dbo].[F4111Selected] FTRANS WHERE FMSTR.IMITM = FTRANS.ILITM and FTRANS.ILDCT = 'IJ')
THEN 'IJ',
ELSE 'OTHERS'
END,
[Inventory Adjustment] =
CASE
WHEN (select FTRANS.ILDCT FROM [TP].[dbo].[F4111Selected] FTRANS
WHERE FMSTR.IMITM = FTRANS.ILITM and FTRANS.ILDCT = 'IA')
THEN 'IA'
ELSE 'OTHERS'
END ,ABS(ILTRQT) AS RECV_QTY,ILUNCS AS UNIT_PRICE
FROM [TP].[dbo].[F4111Selected] FTRANS INNER JOIN dbo.F4101Sel FMSTR
ON FMSTR.IMITM = FTRANS.ILITM
GROUP BY FMSTR.IMITM,FMSTR.IMSRP6_UDC,FTRANS.ILDCT,ILTRDJ,I LTRQT,ILUNCS
ORDER BY ILTRDJ,DATEPART(MONTH,ILTRDJ),FMSTR.IMITM
In the dataset we have an column named document type which has three entries like Issues, Recipts and adjustement.
and we also have another columns like QTY, and Unitprice for these three entries in the same table. My requirment is some thing like I need to segregate these three entries as seperate columns like Recipts, Issues and Adjustment in my target table with there corresponding entries (qty and unitprice)!!!
I have used an case statement in the above mentioned in query whiile at the time of query execution it is giving me something like
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '='.
Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'THEN'.
Msg 156, Level 15, State 1, Line 13
Incorrect syntax near the keyword 'THEN'.
Msg 156, Level 15, State 1, Line 20
Incorrect syntax near the keyword 'THEN'.
Pls do help me out to resolve this query as this is an urgent requirement!!!
Kindly feel free to revert back for clarrifications!!!
Thanks and Regards
Arun Menon D
2 1979
Dear Folks,
I have an query which something looks like this
select ILTRDJ AS YEAR, DATEPART(MONTH,ILTRDJ) AS MONTH,
FMSTR.IMITM AS CODE,FMSTR.IMSRP6_UDC AS DESCRIPTION, FTRANS.ILDCT [Recieved] =
CASE
WHEN (select FTRANS.ILDCT FROM [TP].[dbo].[F4111Selected] FTRANS
WHERE FMSTR.IMITM = FTRANS.ILITM and FTRANS.ILDCT = 'OV')
THEN 'OV'
ELSE 'OTHERS'
END,
[Issued Job] =
CASE
WHEN (select FTRANS.ILDCT FROM [TP].[dbo].[F4111Selected] FTRANS WHERE FMSTR.IMITM = FTRANS.ILITM and FTRANS.ILDCT = 'IJ')
THEN 'IJ',
ELSE 'OTHERS'
END,
[Inventory Adjustment] =
CASE
WHEN (select FTRANS.ILDCT FROM [TP].[dbo].[F4111Selected] FTRANS
WHERE FMSTR.IMITM = FTRANS.ILITM and FTRANS.ILDCT = 'IA')
THEN 'IA'
ELSE 'OTHERS'
END ,ABS(ILTRQT) AS RECV_QTY,ILUNCS AS UNIT_PRICE
FROM [TP].[dbo].[F4111Selected] FTRANS INNER JOIN dbo.F4101Sel FMSTR
ON FMSTR.IMITM = FTRANS.ILITM
GROUP BY FMSTR.IMITM,FMSTR.IMSRP6_UDC,FTRANS.ILDCT,ILTRDJ,I LTRQT,ILUNCS
ORDER BY ILTRDJ,DATEPART(MONTH,ILTRDJ),FMSTR.IMITM
In the dataset we have an column named document type which has three entries like Issues, Recipts and adjustement.
and we also have another columns like QTY, and Unitprice for these three entries in the same table. My requirment is some thing like I need to segregate these three entries as seperate columns like Recipts, Issues and Adjustment in my target table with there corresponding entries (qty and unitprice)!!!
I have used an case statement in the above mentioned in query whiile at the time of query execution it is giving me something like
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '='.
Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'THEN'.
Msg 156, Level 15, State 1, Line 13
Incorrect syntax near the keyword 'THEN'.
Msg 156, Level 15, State 1, Line 20
Incorrect syntax near the keyword 'THEN'.
Pls do help me out to resolve this query as this is an urgent requirement!!!
Kindly feel free to revert back for clarrifications!!!
Thanks and Regards
Arun Menon D
I don't think you still need subquery.
Try following this pattern: - [Recieved] =
-
CASE
-
WHEN FTRANS.ILDCT = 'OV'
-
THEN 'OV'
-
ELSE 'OTHERS'
-
END,
-
-
[Issued Job] =
-
CASE
-
WHEN FTRANS.ILDCT = 'IJ'
-
THEN 'IJ',
-
ELSE 'OTHERS'
-
END,
-
[Inventory Adjustment] =
-
CASE
-
WHEN FTRANS.ILDCT = 'IA'
-
THEN 'IA'
-
ELSE 'OTHERS'
This portion "FMSTR.IMITM = FTRANS.ILITM" has been taken care of by your JOIN.
-- CK
Hi,
Thanks for your reply and it worked well!!!!
Regards
Arun Menon D
I don't think you still need subquery.
Try following this pattern: - [Recieved] =
-
CASE
-
WHEN FTRANS.ILDCT = 'OV'
-
THEN 'OV'
-
ELSE 'OTHERS'
-
END,
-
-
[Issued Job] =
-
CASE
-
WHEN FTRANS.ILDCT = 'IJ'
-
THEN 'IJ',
-
ELSE 'OTHERS'
-
END,
-
[Inventory Adjustment] =
-
CASE
-
WHEN FTRANS.ILDCT = 'IA'
-
THEN 'IA'
-
ELSE 'OTHERS'
This portion "FMSTR.IMITM = FTRANS.ILITM" has been taken care of by your JOIN.
-- CK
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: richasaraf |
last post by:
Hello everyone,
I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then basic problem is the...
|
by: richasaraf |
last post by:
Hello everyone,
Please HELP !!!!!
I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then...
|
by: clueless_google |
last post by:
hello. i've been beating my head against a wall over this for too
long.
setting the variables 'z' or 'y' to differing numbers, the following
'if/else' code snippet works fine; however, the ...
|
by: Chih-Hsu Yen |
last post by:
I encountered a strange problem about switch-case statement.
switch(cmd)
{
case 1: statements; break;
case 2: statements; break;
... ....
case 11: S1;
S2;
S3;
statements;
|
by: Brett Romero |
last post by:
If I want to use:
switch (AppName)
{
case ApplicationName.App1:
loadApp1Logo();
break;
case ApplicationName.App2:
loadApp2Logo();
break;
|
by: Navodit |
last post by:
So I have some code like:
if (document.Insurance.State.selectedIndex == 1)
{
ifIll();
}
else if (document.Insurance.State.selectedIndex == 2)
{
elseKan();
}
|
by: Patrick A |
last post by:
All,
I rely on nested IF statements with multiple conditions heavily, and
someone suggested recently writing the statements (and especially
reading them months later) would be much easier if I...
|
by: Satya |
last post by:
Hi everyone,
This is the first time iam posting excuse me if iam making any
mistake. My question is iam using a switch case statement in which i
have around 100 case statements to compare. so...
|
by: Adem |
last post by:
C/C++ language proposal:
Change the 'case expression' from "integral constant-expression" to "integral expression"
The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15)
says under...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
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...
|
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,...
| |