'Converting MySQL query to KnexJS query
I am trying to convert a MySQL query, but i still couldn't get any result.
MySQL to knex js query, if anyone can help :
the MySQL query is :
`SELECT GROUP_CONCAT(A.Jan, ", ", A.Feb, ", ", A.Mar, ", ", A.Apr, ", ", A.May, ", ", A.Jun, ", ", A.Jul, ", ", A.Aug, ", ", A.Sep, ", ", A.Oct, ", ", A.Nov, ", ", A.Dec) AS total_per_month, (SELECT
SUM(if(MONTH(userRegistrationDate) = 1, 1,0)) as Jan,
SUM(if(MONTH(userRegistrationDate) = 2, 1,0)) as Feb,
SUM(if(MONTH(userRegistrationDate) = 3, 1,0)) as Mar,
SUM(if(MONTH(userRegistrationDate) = 4, 1,0)) as Apr,
SUM(if(MONTH(userRegistrationDate) = 5, 1,0)) as May,
SUM(if(MONTH(userRegistrationDate) = 6, 1,0)) as Jun,
SUM(if(MONTH(userRegistrationDate) = 7, 1,0)) as Jul,
SUM(if(MONTH(userRegistrationDate) = 8, 1,0)) as Aug,
SUM(if(MONTH(userRegistrationDate) = 9, 1,0)) as Sep,
SUM(if(MONTH(userRegistrationDate) = 10, 1,0)) as Oct,
SUM(if(MONTH(userRegistrationDate) = 11, 1,0)) as Nov,
SUM(if(MONTH(userRegistrationDate) = 12, 1,0)) as Dec
FROM user
WHERE YEAR(NOW())) A`
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
