Count of employee Registered/ verified on per day basis












0















I am working on Spring MVC based web application I implemented the graphical representation of data relevant for my client.
its very simple I need to illustrate the counts of registered Employees and Verified Employees on per day registration and verification basis.



I wrote a below query,



 SELECT monthyear 
,SUM(CASE WHEN type='1' THEN total ELSE 0 END )as tot_ver
,SUM(CASE WHEN type='2' THEN total ELSE 0 END )as tot_reg
FROM (
SELECT
TO_CHAR(verify_date,'YYYY-mm-dd') as monthyear
,SUM(CASE WHEN verify_status=1 THEN 1 ELSE 0 END )as total
,'1' as type
FROM EMPLOYEE
GROUP BY TO_CHAR(verify_date,'YYYY-mm-dd')
UNION ALL
SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear
,SUM(CASE WHEN emp_id!=0 THEN 1 ELSE 0 END )as total
,'2' as type
FROM EMPLOYEE
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd')
)
where monthyear IS NOT NULL
GROUP BY monthyear
ORDER BY monthyear


And JAVA CODE



 public TwoValueBean totRegisterUser() {
String query = " SELECT monthyear"
+ " ,SUM(CASE WHEN type='1' THEN total ELSE 0 END )as tot_ver"
+ " ,SUM(CASE WHEN type='2' THEN total ELSE 0 END )as tot_reg "
+ " FROM ("
+ " SELECT "
+ " TO_CHAR(verify_date,'YYYY-mm') as monthyear"
+ " ,SUM(CASE WHEN verify_status=1 THEN 1 ELSE 0 END )as total"
+ " ,'1' as type "
+ " FROM EMPLOYEE"
+ " GROUP BY TO_CHAR(verify_date,'YYYY-mm') "
+ " UNION ALL"
+ " SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear "
+ " ,SUM(CASE WHEN emp_id!=0 THEN 1 ELSE 0 END )as total"
+ " ,'2' as type"
+ " FROM EMPLOYEE"
+ " GROUP BY TO_CHAR(add_date,'YYYY-mm')"
+ " ) "
+ " where monthyear IS NOT NULL "
+ " GROUP BY monthyear"
+ " ORDER BY monthyear";
MapSqlParameterSource param = new MapSqlParameterSource();
TwoValueBean bean = new TwoValueBean();
try {
List<TotalRegisterGraphData> list = getNamedParameterJdbcTemplate().query(query, param, new RowMapper<TotalRegisterGraphData>() {

@Override
public TotalRegisterGraphData mapRow(ResultSet rs, int rowNo) throws SQLException {
TotalRegisterGraphData regData = new TotalRegisterGraphData();
regData.setRegMonth(rs.getString("monthyear"));
regData.setTotRegister(rs.getLong("tot_reg"));
regData.setTotVerify(rs.getLong("tot_ver"));
return regData;
}
});
if (list != null && list.size() > 0) {
String reqDate = "";
List<String> val1 = new ArrayList<String>();
List<String> val2 = new ArrayList<String>();
List<String> val3 = new ArrayList<String>();
int currentVer = 0;
int currentReg = 0;
for (TotalRegisterGraphData data : list) {
currentReg += data.getTotRegister();
currentVer += data.getTotVerify();
val1.add("'" +data.getRegMonth()+ "'");
val2.add(String.valueOf(currentReg));
val3.add(String.valueOf(currentVer));
}
bean.setVal1(StringProcessorUtil.arrayToString(val1.toArray(new String{}), null));
bean.setVal2(StringProcessorUtil.arrayToString(val2.toArray(new String{}), null));
bean.setVal3(StringProcessorUtil.arrayToString(val3.toArray(new String{}), null));
}
} catch (Exception e) {
e.printStackTrace();
}
return bean;
}
}


As you people can see,query fetches the data on behalf of the day of registration, but it is also point to be notice, it add up the count, as soon as user getting registered it shows the maximum count at particular date.



What I want, i need the exact registered employee count on specific day.



For example: if 50 employee will be register on 24-11-2018 then the count should be illustrated as 50 , not 50 + all previous registration.



Similar case arise for Verified Employee.



Registration is first phase (In query, tot_reg, holds the count)
Verification is final phase (In query, tot_ver, holds the count)



Registration can be get by add_date
and
verification can be get by verify_date.



For more clarity i also attached the graph image n which the blue lines show the registered employees and black lines shows the verified employee count, but you people can observe than, it shows the maximum count on specific date.
enter image description here
for example.
if 1 person is registered then it shows 1 on 01-01-2018
if 1 more person registered on next two days, then it shows 2
if 2 people registered on 05-01-2018, then it shows 4



I don't want this to be happen, I want per day user registered count.



if 10 person registered on 08-01-2018, then is should shows 10
if another 20 person registered on 09-01-2018, then it shows 20
similarly for verified employee










share|improve this question

























  • Consider removing the SQL tag from this question

    – Caius Jard
    Nov 23 '18 at 18:22
















0















I am working on Spring MVC based web application I implemented the graphical representation of data relevant for my client.
its very simple I need to illustrate the counts of registered Employees and Verified Employees on per day registration and verification basis.



I wrote a below query,



 SELECT monthyear 
,SUM(CASE WHEN type='1' THEN total ELSE 0 END )as tot_ver
,SUM(CASE WHEN type='2' THEN total ELSE 0 END )as tot_reg
FROM (
SELECT
TO_CHAR(verify_date,'YYYY-mm-dd') as monthyear
,SUM(CASE WHEN verify_status=1 THEN 1 ELSE 0 END )as total
,'1' as type
FROM EMPLOYEE
GROUP BY TO_CHAR(verify_date,'YYYY-mm-dd')
UNION ALL
SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear
,SUM(CASE WHEN emp_id!=0 THEN 1 ELSE 0 END )as total
,'2' as type
FROM EMPLOYEE
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd')
)
where monthyear IS NOT NULL
GROUP BY monthyear
ORDER BY monthyear


And JAVA CODE



 public TwoValueBean totRegisterUser() {
String query = " SELECT monthyear"
+ " ,SUM(CASE WHEN type='1' THEN total ELSE 0 END )as tot_ver"
+ " ,SUM(CASE WHEN type='2' THEN total ELSE 0 END )as tot_reg "
+ " FROM ("
+ " SELECT "
+ " TO_CHAR(verify_date,'YYYY-mm') as monthyear"
+ " ,SUM(CASE WHEN verify_status=1 THEN 1 ELSE 0 END )as total"
+ " ,'1' as type "
+ " FROM EMPLOYEE"
+ " GROUP BY TO_CHAR(verify_date,'YYYY-mm') "
+ " UNION ALL"
+ " SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear "
+ " ,SUM(CASE WHEN emp_id!=0 THEN 1 ELSE 0 END )as total"
+ " ,'2' as type"
+ " FROM EMPLOYEE"
+ " GROUP BY TO_CHAR(add_date,'YYYY-mm')"
+ " ) "
+ " where monthyear IS NOT NULL "
+ " GROUP BY monthyear"
+ " ORDER BY monthyear";
MapSqlParameterSource param = new MapSqlParameterSource();
TwoValueBean bean = new TwoValueBean();
try {
List<TotalRegisterGraphData> list = getNamedParameterJdbcTemplate().query(query, param, new RowMapper<TotalRegisterGraphData>() {

@Override
public TotalRegisterGraphData mapRow(ResultSet rs, int rowNo) throws SQLException {
TotalRegisterGraphData regData = new TotalRegisterGraphData();
regData.setRegMonth(rs.getString("monthyear"));
regData.setTotRegister(rs.getLong("tot_reg"));
regData.setTotVerify(rs.getLong("tot_ver"));
return regData;
}
});
if (list != null && list.size() > 0) {
String reqDate = "";
List<String> val1 = new ArrayList<String>();
List<String> val2 = new ArrayList<String>();
List<String> val3 = new ArrayList<String>();
int currentVer = 0;
int currentReg = 0;
for (TotalRegisterGraphData data : list) {
currentReg += data.getTotRegister();
currentVer += data.getTotVerify();
val1.add("'" +data.getRegMonth()+ "'");
val2.add(String.valueOf(currentReg));
val3.add(String.valueOf(currentVer));
}
bean.setVal1(StringProcessorUtil.arrayToString(val1.toArray(new String{}), null));
bean.setVal2(StringProcessorUtil.arrayToString(val2.toArray(new String{}), null));
bean.setVal3(StringProcessorUtil.arrayToString(val3.toArray(new String{}), null));
}
} catch (Exception e) {
e.printStackTrace();
}
return bean;
}
}


As you people can see,query fetches the data on behalf of the day of registration, but it is also point to be notice, it add up the count, as soon as user getting registered it shows the maximum count at particular date.



What I want, i need the exact registered employee count on specific day.



For example: if 50 employee will be register on 24-11-2018 then the count should be illustrated as 50 , not 50 + all previous registration.



Similar case arise for Verified Employee.



Registration is first phase (In query, tot_reg, holds the count)
Verification is final phase (In query, tot_ver, holds the count)



Registration can be get by add_date
and
verification can be get by verify_date.



For more clarity i also attached the graph image n which the blue lines show the registered employees and black lines shows the verified employee count, but you people can observe than, it shows the maximum count on specific date.
enter image description here
for example.
if 1 person is registered then it shows 1 on 01-01-2018
if 1 more person registered on next two days, then it shows 2
if 2 people registered on 05-01-2018, then it shows 4



I don't want this to be happen, I want per day user registered count.



if 10 person registered on 08-01-2018, then is should shows 10
if another 20 person registered on 09-01-2018, then it shows 20
similarly for verified employee










share|improve this question

























  • Consider removing the SQL tag from this question

    – Caius Jard
    Nov 23 '18 at 18:22














0












0








0








I am working on Spring MVC based web application I implemented the graphical representation of data relevant for my client.
its very simple I need to illustrate the counts of registered Employees and Verified Employees on per day registration and verification basis.



I wrote a below query,



 SELECT monthyear 
,SUM(CASE WHEN type='1' THEN total ELSE 0 END )as tot_ver
,SUM(CASE WHEN type='2' THEN total ELSE 0 END )as tot_reg
FROM (
SELECT
TO_CHAR(verify_date,'YYYY-mm-dd') as monthyear
,SUM(CASE WHEN verify_status=1 THEN 1 ELSE 0 END )as total
,'1' as type
FROM EMPLOYEE
GROUP BY TO_CHAR(verify_date,'YYYY-mm-dd')
UNION ALL
SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear
,SUM(CASE WHEN emp_id!=0 THEN 1 ELSE 0 END )as total
,'2' as type
FROM EMPLOYEE
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd')
)
where monthyear IS NOT NULL
GROUP BY monthyear
ORDER BY monthyear


And JAVA CODE



 public TwoValueBean totRegisterUser() {
String query = " SELECT monthyear"
+ " ,SUM(CASE WHEN type='1' THEN total ELSE 0 END )as tot_ver"
+ " ,SUM(CASE WHEN type='2' THEN total ELSE 0 END )as tot_reg "
+ " FROM ("
+ " SELECT "
+ " TO_CHAR(verify_date,'YYYY-mm') as monthyear"
+ " ,SUM(CASE WHEN verify_status=1 THEN 1 ELSE 0 END )as total"
+ " ,'1' as type "
+ " FROM EMPLOYEE"
+ " GROUP BY TO_CHAR(verify_date,'YYYY-mm') "
+ " UNION ALL"
+ " SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear "
+ " ,SUM(CASE WHEN emp_id!=0 THEN 1 ELSE 0 END )as total"
+ " ,'2' as type"
+ " FROM EMPLOYEE"
+ " GROUP BY TO_CHAR(add_date,'YYYY-mm')"
+ " ) "
+ " where monthyear IS NOT NULL "
+ " GROUP BY monthyear"
+ " ORDER BY monthyear";
MapSqlParameterSource param = new MapSqlParameterSource();
TwoValueBean bean = new TwoValueBean();
try {
List<TotalRegisterGraphData> list = getNamedParameterJdbcTemplate().query(query, param, new RowMapper<TotalRegisterGraphData>() {

@Override
public TotalRegisterGraphData mapRow(ResultSet rs, int rowNo) throws SQLException {
TotalRegisterGraphData regData = new TotalRegisterGraphData();
regData.setRegMonth(rs.getString("monthyear"));
regData.setTotRegister(rs.getLong("tot_reg"));
regData.setTotVerify(rs.getLong("tot_ver"));
return regData;
}
});
if (list != null && list.size() > 0) {
String reqDate = "";
List<String> val1 = new ArrayList<String>();
List<String> val2 = new ArrayList<String>();
List<String> val3 = new ArrayList<String>();
int currentVer = 0;
int currentReg = 0;
for (TotalRegisterGraphData data : list) {
currentReg += data.getTotRegister();
currentVer += data.getTotVerify();
val1.add("'" +data.getRegMonth()+ "'");
val2.add(String.valueOf(currentReg));
val3.add(String.valueOf(currentVer));
}
bean.setVal1(StringProcessorUtil.arrayToString(val1.toArray(new String{}), null));
bean.setVal2(StringProcessorUtil.arrayToString(val2.toArray(new String{}), null));
bean.setVal3(StringProcessorUtil.arrayToString(val3.toArray(new String{}), null));
}
} catch (Exception e) {
e.printStackTrace();
}
return bean;
}
}


As you people can see,query fetches the data on behalf of the day of registration, but it is also point to be notice, it add up the count, as soon as user getting registered it shows the maximum count at particular date.



What I want, i need the exact registered employee count on specific day.



For example: if 50 employee will be register on 24-11-2018 then the count should be illustrated as 50 , not 50 + all previous registration.



Similar case arise for Verified Employee.



Registration is first phase (In query, tot_reg, holds the count)
Verification is final phase (In query, tot_ver, holds the count)



Registration can be get by add_date
and
verification can be get by verify_date.



For more clarity i also attached the graph image n which the blue lines show the registered employees and black lines shows the verified employee count, but you people can observe than, it shows the maximum count on specific date.
enter image description here
for example.
if 1 person is registered then it shows 1 on 01-01-2018
if 1 more person registered on next two days, then it shows 2
if 2 people registered on 05-01-2018, then it shows 4



I don't want this to be happen, I want per day user registered count.



if 10 person registered on 08-01-2018, then is should shows 10
if another 20 person registered on 09-01-2018, then it shows 20
similarly for verified employee










share|improve this question
















I am working on Spring MVC based web application I implemented the graphical representation of data relevant for my client.
its very simple I need to illustrate the counts of registered Employees and Verified Employees on per day registration and verification basis.



I wrote a below query,



 SELECT monthyear 
,SUM(CASE WHEN type='1' THEN total ELSE 0 END )as tot_ver
,SUM(CASE WHEN type='2' THEN total ELSE 0 END )as tot_reg
FROM (
SELECT
TO_CHAR(verify_date,'YYYY-mm-dd') as monthyear
,SUM(CASE WHEN verify_status=1 THEN 1 ELSE 0 END )as total
,'1' as type
FROM EMPLOYEE
GROUP BY TO_CHAR(verify_date,'YYYY-mm-dd')
UNION ALL
SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear
,SUM(CASE WHEN emp_id!=0 THEN 1 ELSE 0 END )as total
,'2' as type
FROM EMPLOYEE
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd')
)
where monthyear IS NOT NULL
GROUP BY monthyear
ORDER BY monthyear


And JAVA CODE



 public TwoValueBean totRegisterUser() {
String query = " SELECT monthyear"
+ " ,SUM(CASE WHEN type='1' THEN total ELSE 0 END )as tot_ver"
+ " ,SUM(CASE WHEN type='2' THEN total ELSE 0 END )as tot_reg "
+ " FROM ("
+ " SELECT "
+ " TO_CHAR(verify_date,'YYYY-mm') as monthyear"
+ " ,SUM(CASE WHEN verify_status=1 THEN 1 ELSE 0 END )as total"
+ " ,'1' as type "
+ " FROM EMPLOYEE"
+ " GROUP BY TO_CHAR(verify_date,'YYYY-mm') "
+ " UNION ALL"
+ " SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear "
+ " ,SUM(CASE WHEN emp_id!=0 THEN 1 ELSE 0 END )as total"
+ " ,'2' as type"
+ " FROM EMPLOYEE"
+ " GROUP BY TO_CHAR(add_date,'YYYY-mm')"
+ " ) "
+ " where monthyear IS NOT NULL "
+ " GROUP BY monthyear"
+ " ORDER BY monthyear";
MapSqlParameterSource param = new MapSqlParameterSource();
TwoValueBean bean = new TwoValueBean();
try {
List<TotalRegisterGraphData> list = getNamedParameterJdbcTemplate().query(query, param, new RowMapper<TotalRegisterGraphData>() {

@Override
public TotalRegisterGraphData mapRow(ResultSet rs, int rowNo) throws SQLException {
TotalRegisterGraphData regData = new TotalRegisterGraphData();
regData.setRegMonth(rs.getString("monthyear"));
regData.setTotRegister(rs.getLong("tot_reg"));
regData.setTotVerify(rs.getLong("tot_ver"));
return regData;
}
});
if (list != null && list.size() > 0) {
String reqDate = "";
List<String> val1 = new ArrayList<String>();
List<String> val2 = new ArrayList<String>();
List<String> val3 = new ArrayList<String>();
int currentVer = 0;
int currentReg = 0;
for (TotalRegisterGraphData data : list) {
currentReg += data.getTotRegister();
currentVer += data.getTotVerify();
val1.add("'" +data.getRegMonth()+ "'");
val2.add(String.valueOf(currentReg));
val3.add(String.valueOf(currentVer));
}
bean.setVal1(StringProcessorUtil.arrayToString(val1.toArray(new String{}), null));
bean.setVal2(StringProcessorUtil.arrayToString(val2.toArray(new String{}), null));
bean.setVal3(StringProcessorUtil.arrayToString(val3.toArray(new String{}), null));
}
} catch (Exception e) {
e.printStackTrace();
}
return bean;
}
}


As you people can see,query fetches the data on behalf of the day of registration, but it is also point to be notice, it add up the count, as soon as user getting registered it shows the maximum count at particular date.



What I want, i need the exact registered employee count on specific day.



For example: if 50 employee will be register on 24-11-2018 then the count should be illustrated as 50 , not 50 + all previous registration.



Similar case arise for Verified Employee.



Registration is first phase (In query, tot_reg, holds the count)
Verification is final phase (In query, tot_ver, holds the count)



Registration can be get by add_date
and
verification can be get by verify_date.



For more clarity i also attached the graph image n which the blue lines show the registered employees and black lines shows the verified employee count, but you people can observe than, it shows the maximum count on specific date.
enter image description here
for example.
if 1 person is registered then it shows 1 on 01-01-2018
if 1 more person registered on next two days, then it shows 2
if 2 people registered on 05-01-2018, then it shows 4



I don't want this to be happen, I want per day user registered count.



if 10 person registered on 08-01-2018, then is should shows 10
if another 20 person registered on 09-01-2018, then it shows 20
similarly for verified employee







sql spring-mvc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 18:17







user9634982

















asked Nov 23 '18 at 18:11









user9634982user9634982

9911




9911













  • Consider removing the SQL tag from this question

    – Caius Jard
    Nov 23 '18 at 18:22



















  • Consider removing the SQL tag from this question

    – Caius Jard
    Nov 23 '18 at 18:22

















Consider removing the SQL tag from this question

– Caius Jard
Nov 23 '18 at 18:22





Consider removing the SQL tag from this question

– Caius Jard
Nov 23 '18 at 18:22












1 Answer
1






active

oldest

votes


















1














Your SQL query returns the data you're requesting, i.e. it returns the day (which you have confusingly called monthyear) and the count of employees registered/verified on that day



It is your Java code that is accumulating the counts



Change these:



currentReg += data.getTotRegister();
currentVer += data.getTotVerify();


To this:



currentReg = data.getTotRegister();
currentVer = data.getTotVerify();


Note, there appears to be a bug in the query:



SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear --month precision, will give repeated rows
...
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd') --day precision


And your query as pasted in the top box, doesn't match the query in the java code






share|improve this answer
























  • Ohhhkk thanks so much, but don't you think, that for each iteration I loss the previous values

    – user9634982
    Nov 23 '18 at 18:44











  • Erm. That's what you asked for?

    – Caius Jard
    Nov 23 '18 at 18:50











  • ohkk then suggest me solution so i can keep track my each value per iteration

    – user9634982
    Nov 23 '18 at 19:26











  • have 4 variables; 2 that do your += and 2 that do your = ?

    – Caius Jard
    Nov 23 '18 at 20:36











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451302%2fcount-of-employee-registered-verified-on-per-day-basis%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Your SQL query returns the data you're requesting, i.e. it returns the day (which you have confusingly called monthyear) and the count of employees registered/verified on that day



It is your Java code that is accumulating the counts



Change these:



currentReg += data.getTotRegister();
currentVer += data.getTotVerify();


To this:



currentReg = data.getTotRegister();
currentVer = data.getTotVerify();


Note, there appears to be a bug in the query:



SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear --month precision, will give repeated rows
...
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd') --day precision


And your query as pasted in the top box, doesn't match the query in the java code






share|improve this answer
























  • Ohhhkk thanks so much, but don't you think, that for each iteration I loss the previous values

    – user9634982
    Nov 23 '18 at 18:44











  • Erm. That's what you asked for?

    – Caius Jard
    Nov 23 '18 at 18:50











  • ohkk then suggest me solution so i can keep track my each value per iteration

    – user9634982
    Nov 23 '18 at 19:26











  • have 4 variables; 2 that do your += and 2 that do your = ?

    – Caius Jard
    Nov 23 '18 at 20:36
















1














Your SQL query returns the data you're requesting, i.e. it returns the day (which you have confusingly called monthyear) and the count of employees registered/verified on that day



It is your Java code that is accumulating the counts



Change these:



currentReg += data.getTotRegister();
currentVer += data.getTotVerify();


To this:



currentReg = data.getTotRegister();
currentVer = data.getTotVerify();


Note, there appears to be a bug in the query:



SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear --month precision, will give repeated rows
...
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd') --day precision


And your query as pasted in the top box, doesn't match the query in the java code






share|improve this answer
























  • Ohhhkk thanks so much, but don't you think, that for each iteration I loss the previous values

    – user9634982
    Nov 23 '18 at 18:44











  • Erm. That's what you asked for?

    – Caius Jard
    Nov 23 '18 at 18:50











  • ohkk then suggest me solution so i can keep track my each value per iteration

    – user9634982
    Nov 23 '18 at 19:26











  • have 4 variables; 2 that do your += and 2 that do your = ?

    – Caius Jard
    Nov 23 '18 at 20:36














1












1








1







Your SQL query returns the data you're requesting, i.e. it returns the day (which you have confusingly called monthyear) and the count of employees registered/verified on that day



It is your Java code that is accumulating the counts



Change these:



currentReg += data.getTotRegister();
currentVer += data.getTotVerify();


To this:



currentReg = data.getTotRegister();
currentVer = data.getTotVerify();


Note, there appears to be a bug in the query:



SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear --month precision, will give repeated rows
...
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd') --day precision


And your query as pasted in the top box, doesn't match the query in the java code






share|improve this answer













Your SQL query returns the data you're requesting, i.e. it returns the day (which you have confusingly called monthyear) and the count of employees registered/verified on that day



It is your Java code that is accumulating the counts



Change these:



currentReg += data.getTotRegister();
currentVer += data.getTotVerify();


To this:



currentReg = data.getTotRegister();
currentVer = data.getTotVerify();


Note, there appears to be a bug in the query:



SELECT TO_CHAR(add_date,'YYYY-mm') as monthyear --month precision, will give repeated rows
...
GROUP BY TO_CHAR(add_date,'YYYY-mm-dd') --day precision


And your query as pasted in the top box, doesn't match the query in the java code







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 18:21









Caius JardCaius Jard

11.9k21239




11.9k21239













  • Ohhhkk thanks so much, but don't you think, that for each iteration I loss the previous values

    – user9634982
    Nov 23 '18 at 18:44











  • Erm. That's what you asked for?

    – Caius Jard
    Nov 23 '18 at 18:50











  • ohkk then suggest me solution so i can keep track my each value per iteration

    – user9634982
    Nov 23 '18 at 19:26











  • have 4 variables; 2 that do your += and 2 that do your = ?

    – Caius Jard
    Nov 23 '18 at 20:36



















  • Ohhhkk thanks so much, but don't you think, that for each iteration I loss the previous values

    – user9634982
    Nov 23 '18 at 18:44











  • Erm. That's what you asked for?

    – Caius Jard
    Nov 23 '18 at 18:50











  • ohkk then suggest me solution so i can keep track my each value per iteration

    – user9634982
    Nov 23 '18 at 19:26











  • have 4 variables; 2 that do your += and 2 that do your = ?

    – Caius Jard
    Nov 23 '18 at 20:36

















Ohhhkk thanks so much, but don't you think, that for each iteration I loss the previous values

– user9634982
Nov 23 '18 at 18:44





Ohhhkk thanks so much, but don't you think, that for each iteration I loss the previous values

– user9634982
Nov 23 '18 at 18:44













Erm. That's what you asked for?

– Caius Jard
Nov 23 '18 at 18:50





Erm. That's what you asked for?

– Caius Jard
Nov 23 '18 at 18:50













ohkk then suggest me solution so i can keep track my each value per iteration

– user9634982
Nov 23 '18 at 19:26





ohkk then suggest me solution so i can keep track my each value per iteration

– user9634982
Nov 23 '18 at 19:26













have 4 variables; 2 that do your += and 2 that do your = ?

– Caius Jard
Nov 23 '18 at 20:36





have 4 variables; 2 that do your += and 2 that do your = ?

– Caius Jard
Nov 23 '18 at 20:36




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451302%2fcount-of-employee-registered-verified-on-per-day-basis%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Ottavio Pratesi

Tricia Helfer

15 giugno