How to write group by ???
Hi all,
I have problem with GROUP BY clause.
My query is
select case .........end shift, t.*
from table1
where ....
gruop by case.....end
Its throws me an error. But if the remove the column "t.*" then if i write the satement
select case .........end shift
from table1
where ....
gruop by case.....end
its fetches me the output.
But I want that column also what I should do, how should i group. Please help me.
Thanks in advance.
Regards
Uraja
The merits of your case statement aside (I agree with all of William's comments), you just need to GROUP BY you case statement as you use it in the SELECT list.
SQL> l
1 SELECT CASE WHEN crea_ts BETWEEN TO_DATE('01-jan-2000','dd-mon-yyyy') and
2 TO_DATE('31-dec-2002','dd-mon-yyyy') THEN 'Oldest'
3 WHEN crea_ts BETWEEN TO_DATE('01-jan-2003','dd-mon-yyyy') and
4 TO_DATE('31-dec-2005','dd-mon-yyyy') THEN 'Old'
5 ELSE 'New' END status, count(*)
6 FROM t
7 GROUP BY CASE WHEN crea_ts BETWEEN TO_DATE('01-jan-2000','dd-mon-yyyy') and
8 TO_DATE('31-dec-2002','dd-mon-yyyy') THEN 'Oldest'
9 WHEN crea_ts BETWEEN TO_DATE('01-jan-2003','dd-mon-yyyy') and
10 TO_DATE('31-dec-2005','dd-mon-yyyy') THEN 'Old' ELSE
11 ELSE 'New' END;
STATUS COUNT(*)
New 20171
Old 6053
Oldest 5623TTFn
Jhon
Similar Messages
-
How to write sql query that display comma suppurated result using Group by
Hi,
I am having data like bellow ,
Above result got from joining two tables VMTAGroupClient,VMTAipNames .
Query i have written to display above result is,
select vgc.VMTAGroupId,vn.VMTAName from VMTAGroupClient vgc inner join VMTAipNames vn
on vgc.VMTAID=vn.VMTANameID group by vgc.VMTAGroupId,vn.VMTAName
using the VMTAGroupId column how to write query to display result result like,
VMTAGroupID VMTAs
1 VMTA1,VMTA3
2 VMTA2,VMTA4,VMTA5
Regards,
Anwar ShaikSatheesh,
Here in my case data need to read from two tables VMTAGroupClient, VMTAipNames.
VMTAGroupId is in one table and VMTAName column in some other table.Iin both the tables VMTAID is common.
Please check the above result displayed data from two tables.
can we write same query using join?
Anwar Shaik -
How to write last 48bits of a bouble variable
hi,
i would like to know how to write last 48bits of double type variable. i am trying create a certain memory format. it needs a 48bits of a one data point. since we C doen't have 48bit variable i created double variable. now i am trying to write last 48bits of this double.(most significant bits). any help would be appreciated.
Thanks,Double variables are treated by CVI according to IEEE 754 standard, which means the 64 bits are organized in groups to represent sign, exponent and mantissa of a floating point library. For this reason it seems to me that you may come into troubles by attempting to use some bits only of a double variable.
If you are not treating floating point numbers, you may consider to use '__int64' data type instead which is supported by CVI starting from release 7.0 on or the equivalent 'long long' data type introduced in CVI 8.5: both describe 8-bytes integers.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
How to write a Globla Routine for Transfer Rules
Hi Experts,
How to write a Global Routine for Tranfer Rules ? Where all the infoobjects need to be grouped? Effect need to be shown on group of fields that are available in a single structure.
Thanks in Advance
VaraHi,
Are you aware of Start Routine available?.. This helps to write a routine on all the infoObjects available in Transfer Structure
http://help.sap.com/saphelp_nw04/helpdata/en/b3/0ef3e8396111d5b2e80050da4c74dc/frameset.htm
regards
Happy Tony -
How to write this query to filter combination of few values
Hi,
I have a table CHIMM which is a transaction table and contains information of the vaccines given to a child.
columns are: child_id, vacc_id, vacc_given_dt. I have to query for remaining vaccines.
HEXA is a vaccine_id which is composite vaccine of DPT1,POL1,HBV1 & HIB1 (vaccine ids).
I want to write to query if any of DPT1,POL1,HBV1 & HIB1 given then HEXA should not be displayed in the result.
OR
if HEXA is given then of course any of DPT1,POL1,HBV1 & HIB1 should not be displayed in the result.
How to write this query?
RegardsHi,
I'm still not sure what the output you want from that sample data is. Do you just want the child_ids, like this
CHILD_ID
3
4? If so, here's one way to get them:
WITH all_vacc_ids AS
SELECT c.child_id
, c.vacc_id AS child_vacc_id
, v.vacc_id
, COUNT ( CASE
WHEN c.vacc_id = 'HEXA'
THEN 1
END
) OVER ( PARTITION BY c.child_id
) AS hexa_itself
FROM vacc v
LEFT OUTER JOIN chimm c PARTITION BY (c.child_id)
ON c.vacc_id = v.vacc_id
WHERE v.vacc_desc = 'HEXA' -- See note below
SELECT child_id
FROM all_vacc_ids
WHERE child_vacc_id IS NULL
AND vacc_id != 'HEXA'
AND hexa_itself = 0
GROUP BY child_id
rha2 wrote:there are alot of vaccines, i just put 3 for example. this query gives error: invalid relational operatorAre you saying that the vacc table contains other rows, but those other rows are not needed for this problem? It would be good if you included an example in the sample data. The query above considers only the rows in vacc where vacc_desc='HEXA'. You can have other rows in the vacc table, but they won't affect the output of this query. The query above makes no assumptions about the number of rows that have vacc_desc='HEXA'; it will report all child_ids who are missing any of them, regardless of the number (assuming the child does not have the 'HEXA' vacc_id itself, like child_id=1).
You still haven't said which version of Oracle you're using. The query above will work in Oracle 10 (and higher). -
How to write this query ?
how to write this query ?
list the emp name who is working for the highest avg sal department.
I can use row_number over to get correct result. If we don't use this row_number function, just plain sql, how to do it ?
the row_number version is like this
select emp.* from emp ,
select deptno, row_number() over (order by avg(sal) desc) r from emp
group by deptno
)e
where e.r = 1
and emp.deptno = e.deptnoHi,
806540 wrote:
how to write this query ?
list the emp name who is working for the highest avg sal department.
I can use row_number over to get correct result. If we don't use this row_number function, just plain sql, how to do it ?ROW_NUMBER is just plain SQL, and has been since Oracle 8.1.
ROW_NUMBER (or its close relative, RANK) is the simplest and most efficient way to solve this problem. Why not do this the right way?
the row_number version is like this
select emp.* from emp ,
select deptno, row_number() over (order by avg(sal) desc) r from emp
group by deptno
)e
where e.r = 1
and emp.deptno = e.deptno
If there happens to be a tie (that is, two or more departments have the same average sal, and it is the highest), then the query above will only arbitrarily treat one of them (no telling which one) as the highest. Change ROW_NUMBER to RANK to get all departments with a claim to having the highest average sal.
You could use the ROWNUM pseudo-column instead of ROW_NUMBER, if all you want to do is avoid ROW_NUMBER.
Without using ROW_NUMBER or RANK, there are lots of ways involving other analytic functions, such as AVG and MAX.
If you really, really don't want to use analytic functions at all, you can do this:
SELECT *
FROM scott.emp
WHERE deptno IN (
SELECT deptno
FROM scott.emp
GROUP BY deptno
HAVING AVG (sal) = (
SELECT MAX (AVG (sal))
FROM scott.emp
GROUP BY deptno
; -
HOW TO WRITE ABAP PROGRAMMING IN JAVA BY USING NETWEAVER
HI,
i am working with bapi(mean is calling bapis in my java programs).
please tell me the how to write abap programs in nwds
Thanqqqqqqqqq
GuruHi,
Refer the following links..
http://manuals.sybase.com/onlinebooks/group-iaw/iag0203e/iadgen2/@Generic__BookTextView/24685
and this blog
/people/kathirvel.balakrishnan2/blog/2005/07/26/remote-enable-your-rfchosttoip-to-return-host-ip-to-jco
Regards,
Uma -
Can any one tell me how to write open hubs to application server?
Hello Everone,
I created open hubs and my requirement is to write the file to application server. So, I created logical file name and logical paths as specified in below link.
http://help.sap.com/SAPHELP_NW04S/helpdata/EN/8d/3e4ec2462a11d189000000e8323d3a/frameset.htm
That is created 'logical file path defination' in 'FILE' transaction. Used the physical path as - 'bw/FTPOUT/BPR/GM/<FILENAME>' as given in above link..
In logical file name I used the above logical file path.
When I run the open hub, I'm getting the ABAP dump "UNCAUGHT_EXCEPTION
CX_RSB_WRITE_ERROR
12/18/2008 09:00:40"
Can any one tell me how to write open hubs to application server?Hi David,
Goto transaction code - FILE
1) Create a Logical File Path definition, enter the technical name and description by clicking new entries and save it.(z_ftp)
2) create a Logical file name definition using cross client,
enter the logical file name = z_ftp , name = ftp , physical file = ftp_test.txt,
dataformat = ASC, Appln area = BW and Logical path = z_ftp(created from step 1).
click SAVE button.
3) Assignment of physical paths to logical paths, choose your logical path here.
enter the syntax group = UNIX
Physical path = /bwftp/....
Save it .
In the openhub,
choose definition type = file
Check the applicaion sever.
servername = dev
type of file name = Logical file
Applin server file name = z_ftp
separator = |
Hope this helps and solve your problem.
Thanks
Sat -
How to write copa0003 's pbo?
hi,Dear professor:
I am trying to add new fields to TC KO01/2/3.
I've read the documentation and did not understand.
I've already created my fields in the CI_AUFK structure.
now I can write the coas-zmenge into the table. but on the user-define screen '0100' , the field of coas-zmenge is still blank,can't display with the value.
Can you give me an example of how to write in EXIT_SAPMKAUF_002 PBO?Hi,
Use the EXIT_SAPMKAUF_003 for updating your custom field....nder the changing field C_USER_CI_AUFK ......
this wil be in PAI ......now under PBO that entered value wil come .....when you are in display mode......
do declare the ield values .....under ZXAUFTOP under the function group XAUF ......so that they wil be available globally ....
Thanks,
Shailaja Ainala. -
How to write a query for the given scenario ?
Hi All ,
I am having two tables EMP, DEPT with the below data.
EMP TABLE :--
EID ENAME JOB SAL DEPID
111 RAM MANAGER 1500 10
222 SAM ASST MANAGER 2000 20
333 KALA CLERK 2500 10
444 BIMA MANAGER 3000 20
555 CHALA MANAGER 3500 30
666 RANI ASST MANAGER 4000 10
777 KAMAL MANAGER 2400 10
DEPT TABLE :--
DEPID DNAME
10 XX
20 YY
30 ZZ
Q1 : I want the sum of salary of each department and for the particular job . Here in each departmant manager, asst. manager, clerk posts are there .
I want to display the result like below ....
JOB 10 20 30
MANAGER 3900 3000 3500
ASST MANAGER 4000 2000 NULL
CLERK 2500 NULL NULL
please tell me how to write a sql query ?
Thanks
SaiIn general case, you cannot write this query.
This is one of the limits of relational database concepts. The number of columns must be known up-front. In the SELECT clause, you have to list and name all columns returned by the query. So you have to know number of departments. (There are some workarounds - you can return one column with concatenated values for all departments, separated by space character).
If you know that you have 3 departments then you qurey will return 4 columns:
SELECT
e.job,
SUM ( CASE WHEN d.deptid = 10 THEN e.sal ELSE NULL END) d10,
SUM ( CASE WHEN d.deptid = 20 THEN e.sal ELSE NULL END) d20,
SUM ( CASE WHEN d.deptid = 30 THEN e.sal ELSE NULL END) d30
FROM dept d, emp e
WHERE d.deptno = e.deptno
GROUP BY e.job -
How to write the tech specification ?
hi can any 1 tell me how to write the technical specification when a functional spec is given.
guys i need a sample spec or format of it . any help is appreciated
please any one send some reports with codeHello Selva
The first link provided by Vijayendra provides an already quite comprehensive specification. What I like in particular is chapter "1.15 Assumptions".
I add a similar chapter to my specifications called <b>"Assertions"</b> which I prefer to place more at the beginning of the document. This chapter contains all assertions (mainly provided by the customer) on which the application is based. For example: <i>"The receiver (of certain costs) is either a single cost center or a cost center group but never both"</i> (technically possible in the SAP transaction).
Within the application I try to document these assertions using checkpoint groups and assertions (more about this in the informative Weblog of Claudia Dangers /people/claudia.dangers/blog/2005/09/07/how-to-instrument-your-abap-code-with-checkpoint-groups).
Why do I place this chapter on top of the specification? The customer should see this assertions/assumptions quite early in order to find any mistakes.
Finally, what I have missed in the specification was a chapter <b>"Authorizations".</b>
Regards
Uwe -
How to write numbers in Arabic?
Hi All,
How to write numbers in arabic?
(how will you in normal papers....assume 123 to be in the arabic numerals here).
Should it be:
| -123|
(or)
| 123-|
Thanks,
JanaTry the following.
DecimalFormat formatter_ar=null;
Numberformat form = NumberFormat.getNumberInstance(new Locale("ar","EG"));
if(form instanceof DecimalFormat) formatter_ar = (DecimalFormat)form;
String str = formatter_ar.format(-123.45);
System.out.println(str); -
How to write a start routine in the trasnformations ?
Hi Experts,
I am working on BI 7, As I want to write a start routine in transformations of 0FIGL_O02 DSO, to allow the GL accounts with cost center data. Already there is a delete statement please find.
*DELETE SOURCE_PACKAGE where BAL_FLAG = 'X'. I had made comment to allow the G/L accounts. since I have some GL Accounts which does'nt have the cost center data, so in this case I have to write a ABAP code to allow this G/L accounts with cost center data.
So Let me know if anyone can help me how to write the ABAP code in the start routine.
Thanks
sekharHi,
Yopu can write the below lines of code adn try
SORT source_package BY Receive nr Type ASCENDING.
DELETE ADJACENT DUPLICATES FROM source_package COMPARING Receive nr Type.
But you should make sure which record of the either rows need to deleted
i.e in
F9001;LU;J001;662;
F9001;LU;J002;662
You need to decide to eliminate 1st or 2nd one.(depends on your requirement) -
How to write the start routine in the transformations ?
Hi Experts,
I am working on BI 7, As I want to write a start routine in transformations of 0FIGL_O02 DSO, to allow the GL accounts with cost center data. Already there is a delete statement please find.
*DELETE SOURCE_PACKAGE where BAL_FLAG = 'X'. I had made comment to allow the G/L accounts. since I have some GL Accounts which does'nt have the cost center data, so in this case I have to write a ABAP code to allow this G/L accounts with cost center data.
So Let me know if anyone can help me how to write the ABAP code in the start routine.
Thanks
sekharHi Experts,
I am working on BI 7, As I want to write a start routine in transformations of 0FIGL_O02 DSO, to allow the GL accounts with cost center data. Already there is a delete statement please find.
*DELETE SOURCE_PACKAGE where BAL_FLAG = 'X'. I had made comment to allow the G/L accounts. since I have some GL Accounts which does'nt have the cost center data, so in this case I have to write a ABAP code to allow this G/L accounts with cost center data.
So Let me know if anyone can help me how to write the ABAP code in the start routine.
Thanks
sekhar -
How to write a pgm to change the existing encrypted password
Hi all,
can anybody tell me how to write a pgm to change the existing encrypted password.
thanks in advance.Well, it's going to depend on how it's implemented in the current system.
But basically it's going to look a lot like the current login actions. Presumably you have something that takes the user ID and password, encrypts the password, looks up the encrypted password in the database matching that user ID, and compares them. This functionality would also take a new password (preferably twice so they can be checked for consistency), and if the existing encrypted passwords match, it will encrypt the new password and put it in the database where the old one was.
And if the application has a mechanism for new users to sign up, it'll look a lot like this as well.
But I'm just guessing. This is all going to depend on how the existing functionality is written. Probably the best thing you can do is talk to a programmer at your organization who has worked on the application, and ask them for help.
Hope this helps anyway.
Maybe you are looking for
-
Error message when trying to import photos into Bridge CS5
Hi, when trying to import photos from a card reader into Bridge CS5, I click "get Photos" and get the following error message: "cannot obtain all files from this device. Please ensure the device is connected properly, or that the battery is charged".
-
Item Interest Calculation for partially cleared items
Hi We need to do interest calculation on Customer Line Items. The T Code we are using is FINT. We have set an interest indicator for Item Interest Calculation, with Interest Calculation based on Items Cleared with Payments. The requirement is that In
-
FAQ: Where can I find a PDF of the Help documentation?
Searching the Help documentation for Premiere Pro is much easier in PDF format. It's also useful to have a PDF of the Help in case you don't have access to the internet. Here is the link: http://blogs.adobe.com/premierepro/2010/08/help-documents-for-
-
Need help with ASR1002X error message : %IOSXE-4-PLATFORM
Hi, I found the following error on my ASR1002x, could some one tell me what is this all about? Cisco IOS Software, IOS-XE Software (X86_64_LINUX_IOSD-UNIVERSAL-M), Version 15.3(1)S, RELEASE SOFTWARE (fc4) t ipt_MASQUERADE i2c_core exportfs mtd_blkdev
-
I want to reactivate my Elements 9 onto my laptop,
I want to reactivate my Elements 9 on my laptop, but it says I have already used 2 devices. 1 is a computer and the other is a laptop that I no longer own. How can I deactivate this so I can use elements 9 on this laptop. Regards