How to fetch count along with other details
I am trying to write a simple Select query that will return a list of
Employee Names from EMPLOYEE_TABLE,and in the second colum a count of the
number of entries for each employee in EMPLOYEE_ATTENDANCE table.
Can anybody suggest how I could do this?
For Example :
I have two tables EMPLOYEE_TABLE and EMPLOYEE_ATTENDENCE .
EMPLOYEE_TABLE:
emp_number emp_name
1 A
2 B
3 C
4 D
EMPLOYEE_ATTENDENCE :
emp_number emp_time
1 8.00
1 8.00
1 8.00
4 8.00
4 9.00
4
4
4
3
3
3
2
Now ,my requirement is I want to fetch the list of employees with emp_name and the number of days
the employee has come(i.e number of entries in the EMPLOYEE_ATTENDENCE table ).
Some like :
A 3
B 1
C 3
D 5
Just you have to join them and group it.
SQL> with emp
2 as
3 (
4 select 1 no, 'A' name from dual
5 union all
6 select 2, 'B' from dual
7 union all
8 select 3, 'C' from dual
9 union all
10 select 4, 'D' from dual
11 ),
12 emp_att
13 as
14 (
15 select 1 no, 8.00 tm from dual
16 union all
17 select 1, 8.00 from dual
18 union all
19 select 1, 8.00 from dual
20 union all
21 select 4, 8.00 from dual
22 union all
23 select 4, 9.00 from dual
24 union all
25 select 4, 0 from dual
26 union all
27 select 4, 0 from dual
28 union all
29 select 4, 0 from dual
30 union all
31 select 3, 0 from dual
32 union all
33 select 3, 0 from dual
34 union all
35 select 3, 0 from dual
36 union all
37 select 2, 0 from dual
38 )
39 select name,count(name)
40 from emp e, emp_att a
41 where e.no = a.no
42 group by name
43 order by name
44 /
N COUNT(NAME)
A 3
B 1
C 3
D 5
Similar Messages
-
How to fetch table_names along with the result
Hi all,
I want to find strucural differences between two kinds of tables .
One is original table and another one is archival table .
All archival table names will have different name from original tables.
Please tell me how to get table name in the below query..
((SELECT column_name, data_type, data_length, data_precision, nullable
FROM user_tab_columns
WHERE table_name LIKE '%X271%HIST'
AND table_name <> 'X271_ELIG_RSPNS_TABLE')
MINUS
(SELECT column_name, data_type, data_length, data_precision, nullable
FROM user_tab_columns
WHERE table_name LIKE '%X271%'
AND table_name NOT LIKE '%WS'
AND table_name NOT LIKE '%_HIST'
AND table_name <> 'X271_ELIG_RSPNS_TABLE')
UNION ALL
((SELECT column_name, data_type, data_length, data_precision, nullable
FROM user_tab_columns
WHERE table_name LIKE '%X271%'
AND table_name NOT LIKE '%WS'
AND table_name NOT LIKE '%_HIST'
AND table_name <> 'X271_ELIG_RSPNS_TABLE')
MINUS
(SELECT column_name, data_type, data_length, data_precision, nullable
FROM user_tab_columns
WHERE table_name LIKE '%X271%HIST'
AND table_name <> 'X271_ELIG_RSPNS_TABLE')));Thanks,
P Prakash
Edited by: prakash on Sep 5, 2011 5:49 AMYou'll have to JOIN instead of MINUS:
SELECT * FROM
(SELECT table_name, column_name, data_type, data_length, data_precision, nullable WHERE table_name = 'orig') orig
INNER JOIN
(SELECT table_name, column_name, data_type, data_length, data_precision, nullable WHERE table_name != 'orig') other
USING(table_name, column_name)
WHERE
orig.data_type != other.data_type OR
orig.data_length != other.data_length OR
...This doesnt show tables whose column names have changed, for that you'll have to use a full outer join:
SELECT * FROM
(SELECT table_name, column_name WHERE table_name = 'orig') orig
INNER JOIN
(SELECT table_name, column_name WHERE table_name != 'orig') other
ON(orig.table_name = other.table_name AND orig.column_name = other.column_name)
WHERE
orig.column_name IS NULL or
other.column_name IS NULLYou could maybe combine these.. i know my oracle 9.2 would fall over if I tried so i didnt :) -
How to show Relevance% along with other columns
I need to retieve the Relevance % in adddition to other columns
in a table? How can I get the Relevance %?
Thanks.The Score(1) does return a number but it is not the number we
are looking for. For example, we have a column, say,
Description in a table. The Decsription column has text,
say, 'Telecom'. Now when we do a query and search on the
description column using the intermedia index for the
word 'Telecom', then the Score(1) should return 100 for that
record since that is the only word in the Decsription column.
Is it possible to do that using intermedia?
Thanks. -
HT5225 how do I get my icloud a/c onto my mailbox along with other email a/c's ?
How do i get move my icloud a/c onto my mailbox along with other email accounts ?
What Mac OS are you using? It should be setup automatically if using 10.7.2 or later after moving to iCloud.
-
I had a drive failure and lost the iWeb file along with other things.
I did manage to save a lot of user file documents but I don't see or
recognize the iWeb site file. It was on a 15" G4 Titanium pb.
I'm trying to find a way, using version 2.0.4 of iWeb on a different
pb to recover the file into the iWeb app or a way to download the site into iWeb.
There are 6 pages of images and text, and it
would be a task for me to recreate the whole thing again. I did
download the site but I don't know how or if I can get iWeb to see it and open it.
Does anyone have any knowledge about this? The link to my site:
<http://web.mac.com/danauerbach>
Any suggestions will be most appreciated.
dan auerbach
[email protected]Unfortunately iWeb cannot read or import previously published files, only generate them. You'll have to recreate your site from scratch.
However, Chapter 2.3 on the iWeb FAQ.org site has tips on using some of the existing files, image, audio, video, etc., from the published site in the recreation of the site.
OT -
How to get spool along with e-mail or FAX
Hi,
I have a requirement where i have to produce a spool even i go for e-mail or FAX option when the script is triggered.
I am using a standard program where it is coded to have either of the option. i.e. either we have to go for a printer or e-mail or FAX.
Could any one suggest me how to get spool along with e-mail or FAX option.
Thanks in advance.Hi,
check this:-[http://help.sap.com/saphelp_nw04/helpdata/en/a5/28d3b9d26211d4b646006094192fe3/frameset.htm]
hope u'll get some idea.
Regards,
Sneha. -
Withholding tax lines are being cleared along with other line items
Hi All,
While doing J1INCHLN(payment making of TDS), system giving error i.e.
"Withholding tax lines are being aleared along with other line items"
Please suggest me in this issue...it would be great help for me.
Thanks,
SaisriHi,
As per my analysis we found some documents, here We have made advance payment to vendors with TDS and again rised invoce to vendors with TDS and these documents have been nockedoff in F-54.
We have many documents of such nature and as per me it is because of these documents the system is throwing error. Pls. advice as to how to proceed on this.
Thanks,
Saisri -
How to build a screen with master detail data
Hi ,expert ,
Someone can teach me how to build a screen with master detail table ?
I wnat to build a screen for user to maintain FERT group and FERT detail list in one screen .
just like this ..
MASTER Block
FERT1
FERT2
FERT3
DETAIL Block
FERT1A1
FERT1A2
FERT1A3
when I double click FERT1 in the Master Block the detail view will show FERT1A1 A2 A3
Thanks for your help ....
Moderator message : Not enough research before posting. Spec dumping not allowed. Thread locked.
Edited by: Vinod Kumar on Jun 13, 2011 1:38 PMAn inefficient way to create the array is to use the build array and a shift register as shown below. It's more effecient in terms of memory management to create the array and then use the replace array subset as shown in the other image. Of course, if you don't need the array inside the loop, just wire the value out of the while loop and on the exit tunnel, right click and select 'Enable Indexing'.
Message Edited by Dennis Knutson on 07-03-2007 10:25 PM
Message Edited by Dennis Knutson on 07-03-2007 10:26 PM
Attachments:
Crude Build Array.PNG 4 KB
Better Build Array.PNG 6 KB -
How to print interest along with dunning letter
HI guys plz
How to print interest along with dunning letter
Many thanks to you
RajuHi,
ABAP development is required for your requirement. Ask your abaper to develop the programme to print dunning letter along with interest
Regards,
Satish Muvva. -
PLD: How to decrease Header along with PLD.
How to Decrease Header along with paper size from A4 to half (Width= 648 Hight= 432),
I am sorry, but I don't know the solution for your problem - like apparently the rest of the SDK community here.
This Forum is (mainly) for SAP Business One SDK.
For questions related to the B1 application itself and around customization the "Implementation" forum in the Channel Partner Solution Network (http://p2p.sap.com/businessoneforum) - or a message to SAP Support - would IMHO be the best options.
Thanks,
Frank
Message was edited by:
Frank Moebius
...but THANKS for the excellent subject you used! I am glad to see someone giving such precise information in the subject! -
How can I count time with labview7?
Hi
How can I count time with labview 7 and NI-DAQmx like I did with labview 6.1 and "count time-easy.vi" (count event or Time.vi).
I have a 6025E and labview 7.0
ThanksI am not sure what you want to do or why..
... but here goes (some suggestions)
If you want to count the time between two events, you have a choice, you may use the Tick Count. Inisitalize it first by getting a timestamp and then do a difference within a loop. The difference will give you the time elapsed in ms.
You can also use the Get Date/Time String or Get Date / Time in seconds and once again take a snapshot when a first even occurs and another snapshot at the next even (at a point where you want to measure elasped time). This method is particularly useful if you want to timestamp an event.
If I didn't answer your question, can you elaborate what you mean by "How can I count time".
Best of luck..
JLV -
How to fetch service order with partucular system status and user status
Hello All,
How to fetch service orders with specific system status and user status.
thanksI want tables or views from where I can fetch service orders. I have to design ALV report based on this.
I want to fetch released service orders with status INIT and RENT.
Here, SYSTEM Status = Released and
USER Status = INIT
RENT
So is there any function module available for the same..... -
How can I share photos with others in other places using ICloud?
If you have iPhoto on an iOS device rather than a Mac, you can create a 'Photo Journal', which is an online gallery hosted on iCloud: details here -
http://help.apple.com/iphoto/ipad/1.0/#blnkaf3ef70a
This facility is not as yet available in iPhoto on a Mac. If you don't have an iOS device you will need to find a third-party alternative. This page examines some options:
http://rfwilmut.net/migrate4 -
Count along with all the records (columns)
CREATE TABLE "EMP"
( "EMPNO" NUMBER(4,0),
"ENAME" VARCHAR2(10 BYTE),
"JOB" VARCHAR2(9 BYTE),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"COMM" NUMBER(7,2),
"DEPTNO" NUMBER(2,0)
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(1000, 'SMITH', 'CLERK', 7902, TO_DATE('12/17/1980 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 800, 20);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
Values
(1000, 'ALLEN', 'SALESMAN', 7698, TO_DATE('02/20/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 1600, 300, 30);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
Values
(1000, 'WARD', 'SALESMAN', 7698, TO_DATE('02/22/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 1250, 500, 30);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(7566, 'JONES', 'MANAGER', 7839, TO_DATE('04/02/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 2975, 20);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
Values
(7654, 'MARTIN', 'SALESMAN', 7698, TO_DATE('09/28/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 1250, 1400, 30);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(7698, 'BLAKE', 'MANAGER', 7839, TO_DATE('05/01/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 2850, 30);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(7782, 'CLARK', 'MANAGER', 7839, TO_DATE('06/09/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 2450, 10);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(7788, 'SCOTT', 'ANALYST', 7566, TO_DATE('04/19/1987 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 3000, 20);
Insert into EMP
(EMPNO, ENAME, JOB, HIREDATE, SAL, DEPTNO)
Values
(7839, 'KING', 'PRESIDENT', TO_DATE('11/17/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 5000, 10);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
Values
(7844, 'TURNER', 'SALESMAN', 7698, TO_DATE('09/08/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 1500, 0, 30);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(7876, 'ADAMS', 'CLERK', 7788, TO_DATE('05/23/1987 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 1100, 20);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(7900, 'JAMES', 'CLERK', 7698, TO_DATE('12/03/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 950, 30);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(7902, 'FORD', 'ANALYST', 7566, TO_DATE('12/03/1981 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 3000, 20);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
Values
(7934, 'MILLER', 'CLERK', 7782, TO_DATE('01/23/1982 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 1300, 10);
COMMIT;On basic execution of this query
select * from empwe get
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO.BUT I NEED THE DATA (columns) ALONG WITH THE COUNT OF THE RECORDS OF empno
SOMETHING LIKE THIS
COUNT EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO.On the whole i need count along with the entire data..
Please adviceLike this ?
SQL> select count(*) OVER( ORDER BY EMPNO RANGE BETWEEN
2 UNBOUNDED PRECEDING AND CURRENT ROW) serial_no,
3 ename,sal FROM EMP;
SERIAL_NO ENAME SAL
1 SMITH 800
2 ALLEN 1600
3 WARD 1250
4 JONES 2975
5 MARTIN 1250
6 BLAKE 2850
7 CLARK 2450
8 SCOTT 3000
9 KING 5000
10 TURNER 1500
11 ADAMS 1100
SERIAL_NO ENAME SAL
12 JAMES 950
13 FORD 3000
14 MILLER 1300
15 999999 100
16 ABCDEFGHIJKLMNOPQRSTUVWXYZAAAAAA 100
17 MY#@ ' "ABC 100
17 rows selected.
{code}
Or
{code}
SQL> select count(*) OVER( ) tot_count,
2 ename,sal FROM EMP;
TOT_COUNT ENAME SAL
17 SMITH 800
17 ALLEN 1600
17 WARD 1250
17 JONES 2975
17 MARTIN 1250
17 BLAKE 2850
17 CLARK 2450
17 SCOTT 3000
17 KING 5000
17 TURNER 1500
17 ADAMS 1100
TOT_COUNT ENAME SAL
17 JAMES 950
17 FORD 3000
17 MILLER 1300
17 999999 100
17 ABCDEFGHIJKLMNOPQRSTUVWXYZAAAAAA 100
17 MY#@ ' "ABC 100
17 rows selected. -
WH tax line items cleared along with Other line items Message no:8I701
hI guru,
When i run J1INCHLN System givem the error is : Withholding tax line items cleared along with other line items, message no:8I701
Pleas any one give solution ..
I also cheked as respective g/l for tds IN FBL3N . All line items are opend.
Also cheked all selection parameter in J1INCHLN and FBL3N .is same .
Why the sys behaviour like this .
Thanks is andvance
MilindHI,
he error is occuring in this part of the
unction Module J_1IEWT_CHALLAN_UPDATE
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
LOOP AT p_t_ausz1.
Select the cleared line item from bseg table.
SELECT SINGLE * FROM bseg INTO p_bseg_tab
WHERE bukrs = p_t_ausz1-bukrs
AND belnr = p_t_ausz1-belnr
AND gjahr = p_t_ausz1-gjahr
AND buzei = p_t_ausz1-buzei
AND ktosl = 'WIT'
AND qsskz NE space .
IF sy-subrc <> 0.
This is not an ewt clearing transaction relevant for challan update.
p_no_with_clear = 'X'.
EXIT.
ELSE.
APPEND p_bseg_tab.
ENDIF.
ENDLOOP.
Even if one line item chosen is not of withholding tax entry, system
should exit by error message.
DESCRIBE TABLE p_bseg_tab LINES p_bseg_lines.
DESCRIBE TABLE p_t_ausz1 LINES p_with_lines.
IF p_bseg_lines > 0.
At least one entry is found in bseg table for challan update. IF p_with_lines NE p_bseg_lines.
At least one line chosen by the user is not for challan updation.
MESSAGE e701(8i).
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
This is a clear case,that you are trying to post some documents
which does not match with the selection parameters.
I feel the above problem could be due to some document/s (open items of
the earlier years)are incorrect which is causing the reported problem.
Kindly run the challan update program for smaller date range so that you
can find the faulty document.
Hope this solves your query.
Reg
Madhu M
Maybe you are looking for
-
What's the difference between "My Contacts" and "All Contacts"?
What's the difference between "My Contacts" and "All Contacts"? I have no other account other then my iCloud account (from what I can tell), but "My Contacts" has a significantly smaller number of contacts then "All Contacts". What's the difference?
-
File XI File scenario - questions
Hi, does anyone have experience with a scenario that XI will be the integration for backend system -> XI -> ~ 300 work station and comunication is done via files.? what can be cons & pros? Also can XI zip files before sending it? thanks, Udi
-
Difference between SAP XI AND PI
hi can any one tell me the techical enhancements in sap pi
-
Number of instances of SingleThreaded servlet
Does anybody know how many instances of a SingleThreaded servlet does WL server create per request? Does it do it in say pool of 5 and then if all 5 are used and a new request comes - does it create another 5 (or so many)? I
-
Hi, I have a External HDD USB 3 compatible device (WD 500 GB 2,5"). I'm pluging it to USB 2 port and Windows 7 say: "this device can perform faster". But when I use the USB 3 port of my device, Windows 7 can not recognize my device. Any idea?