-2
select PER_CODE as [EMP CODE], EXC_DATE as LEAVES
from R5EXCEPTIONS
inner join R5PERSONNEL on PER_CODE = EXC_PERSON

Mention above is my above code. I want to get count of leaves in another column.

Mention below is my code output:

Code Output

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • 2
    As per the question guide, please do not post images of code, data, error messages, etc. - copy or type the text into the question. Please reserve the use of images for diagrams or demonstrating rendering bugs, things that are impossible to describe accurately via text. – Dale K Mar 04 '22 at 09:03
  • 2
    You need to ensure your question contains *both* sample data *and* desired results. – Dale K Mar 04 '22 at 09:04
  • 2
    Use `COUNT`? Your question is completely unclear. Show us some *consumable* sample data (not an image), the expected results, your attempt(s) and explain why they aren't working. Also include the logic you want to get from your sample data to your expected results. – Thom A Mar 04 '22 at 09:05
  • okay I am sorry @Dake K . Actually I am new in this platform. – Abdul Rafay Mar 04 '22 at 09:13
  • Considering the accepted answer, perhaps a [search](https://www.google.co.uk/search?q=COUNT+SQL+SERVER) would have given you all the resources you needed. Learning to use a search engine is a vital life skill in this age. – Thom A Mar 04 '22 at 09:18

2 Answers2

0

You can count the number of leaves by grouping employee code

Select PER_CODE As [EMP CODE] , COUNT(EXC_DATE) as LEAVES from 
R5EXCEPTIONS inner join R5PERSONNEL  on PER_CODE = EXC_PERSON
group by PER_CODE
HariHaravelan
  • 1,041
  • 1
  • 10
  • 19
0

You can use an aggregate SQL query to get the number of PER_CODE events by date.

The following would represent this:

select count(PER_CODE) as [EMP VOL], EXC_DATE as LEAVES
from R5EXCEPTIONS
inner join R5PERSONNEL on PER_CODE = EXC_PERSON
Group by EXC_DATE
Max888
  • 132
  • 6