I discover few time ago and really love dbfiddle, so I made my question with example made with this wonderfull tool :-)
I've a table in my Oracle Database.
see the dbfiddle https://dbfiddle.uk/?rdbms=oracle_11.2&fiddle=2fa4b3440c660f5bba06120c07d48071
I've to add in this table thanks to this query :
INSERT INTO STATS_CLIENT_TEST (CODECLIENT, CODEAXESTAT, CODEELEMENTSTAT, VALEURAXESTATISTIQUECLIENT) SELECT CODECLIENT, 174, 0, 1 FROM STATS_CLIENT_TEST where VALEURAXESTATISTIQUECLIENT='2021'
1000 174 0 1
1000 174 0 1
1002 174 0 1
1003 174 0 1
It's work but, I would like to get the final result here (last):
https://dbfiddle.uk/?rdbms=oracle_11.2&fiddle=e09d1b7c221bfc2259e36590379cbd05
1000 174 0 2
1002 174 0 1
1003 174 0 1
How could I have the result I try to get ?
Thank you :-)
CodePudding user response:
Use the following query in your INSERT INTO
statement:
SELECT CODECLIENT, 174, 0, COUNT(*)
FROM STATS_CLIENT_TEST
where VALEURAXESTATISTIQUECLIENT='2021'
GROUP BY CODECLIENT