Erst Mal ein riesen danke schön dass du mir hilst
Code:
SELECT `u`.`id` AS `Id` , `u`.`businessName` AS `BusinessName` , `u`.`createdOn` AS `AktiviertSeit` ,
(
SELECT count( `qrsjetty`.`scancode`.`id` )
FROM `qrsjetty`.`scancode`
WHERE `qrsjetty`.`scancode`.`barCode_id`
IN (
SELECT `qrsjetty`.`barcode`.`id`
FROM `qrsjetty`.`barcode`
WHERE (
`qrsjetty`.`barcode`.`clientAdminUser_id`=`u`.`id`
)
)
AND DATE_ADD(`u`.`createdOn` ,Interval 1 month) > `scancode`.`scanDateTime`
) AS `ScansMonat 1` ,
(
SELECT count( `qrsjetty`.`scancode`.`id` )
FROM `qrsjetty`.`scancode`
WHERE `qrsjetty`.`scancode`.`barCode_id`
IN (
SELECT `qrsjetty`.`barcode`.`id`
FROM `qrsjetty`.`barcode`
WHERE (
`qrsjetty`.`barcode`.`clientAdminUser_id`=`u`.`id`
)
)
AND (DATE_ADD(`u`.`createdOn` ,Interval 2 month) > `scancode`.scanDateTime) - (DATE_ADD(`u`.`createdOn` ,Interval 1 month) > `scancode`.scanDateTime)
) AS `ScansMonat 2`
,
(
SELECT count( `qrsjetty`.`scancode`.`id` )
FROM `qrsjetty`.`scancode`
WHERE `qrsjetty`.`scancode`.`barCode_id`
IN (
SELECT `qrsjetty`.`barcode`.`id`
FROM `qrsjetty`.`barcode`
WHERE (
`qrsjetty`.`barcode`.`clientAdminUser_id`=`u`.`id`
)
)
AND (DATE_ADD(`u`.`createdOn` ,Interval 3 month) > `scancode`.`scanDateTime`) - (DATE_ADD(`u`.`createdOn` ,Interval 2 month) > `scancode`.`scanDateTime`)
) AS `ScansMonat 3` ,
(
SELECT count( `qrsjetty`.`scancode`.`id` )
FROM `qrsjetty`.`scancode`
WHERE `qrsjetty`.`scancode`.`barCode_id`
IN (
SELECT `qrsjetty`.`barcode`.`id`
FROM `qrsjetty`.`barcode`
WHERE (
`qrsjetty`.`barcode`.`clientAdminUser_id`=`u`.`id`
)
)
AND (DATE_ADD(`u`.`createdOn` ,Interval 4 month) > `scancode`.`scanDateTime`) - (DATE_ADD(`u`.`createdOn` ,Interval 3 month) > `scancode`.`scanDateTime`)
) AS `ScansMonat 4`,
(
SELECT count( `qrsjetty`.`scancode`.`id` )
FROM `qrsjetty`.`scancode`
WHERE `qrsjetty`.`scancode`.`barCode_id`
IN (
SELECT `qrsjetty`.`barcode`.`id`
FROM `qrsjetty`.`barcode`
WHERE (
`qrsjetty`.`barcode`.`clientAdminUser_id`=`u`.`id`
)
)
AND (DATE_ADD(`u`.`createdOn` ,Interval 5 month) > `scancode`.`scanDateTime`)-(DATE_ADD(`u`.`createdOn` ,Interval 4 month) > `scancode`.`scanDateTime`)
) AS `ScansMonat 5`,
(
SELECT count( `qrsjetty`.`scancode`.`id` )
FROM `qrsjetty`.`scancode`
WHERE `qrsjetty`.`scancode`.`barCode_id`
IN (
SELECT `qrsjetty`.`barcode`.`id`
FROM `qrsjetty`.`barcode`
WHERE (
`qrsjetty`.`barcode`.`clientAdminUser_id`=`u`.`id`
)
)
AND (DATE_ADD(`u`.`createdOn` ,Interval 6 month) > `scancode`.`scanDateTime`) - (DATE_ADD(`u`.`createdOn` ,Interval 5 month) > `scancode`.`scanDateTime`)
) AS `ScansMonat 6` ,
(
SELECT count( `qrsjetty`.`scancode`.`id` )
FROM `qrsjetty`.`scancode`
WHERE `qrsjetty`.`scancode`.`barCode_id`
IN (
SELECT `qrsjetty`.`barcode`.`id`
FROM `qrsjetty`.`barcode`
WHERE (
`qrsjetty`.`barcode`.`clientAdminUser_id`=`u`.`id`
)
)
AND (DATE_ADD(`u`.`createdOn` ,Interval 7 month) > `scancode`.`scanDateTime`) - (DATE_ADD(`u`.`createdOn` ,Interval 6 month) > `scancode`.`scanDateTime`)
) AS `ScansMonat 7`
FROM `qrsjetty`.`user` `u`
WHERE `u`.`id` = 119
OR `u`.`id` = 29
ORDER BY `u`.`createdOn` ASC