General Discussion Undecided where to post - do it here. |
Reply to Thread New Thread |
![]() |
#1 |
|
|
![]() |
![]() |
#3 |
|
|
![]() |
![]() |
#4 |
|
|
![]() |
![]() |
#7 |
|
|
![]() |
![]() |
#8 |
|
|
![]() |
![]() |
#9 |
|
|
![]() |
![]() |
#10 |
|
I don't think there are people on the internets that don't know SQL. SELECT reg.region_name REGION, (SELECT u.name FROM fe_users u WHERE u.uid = reg.fe_user) DIRECTORNAME, IFNULL((SELECT sum(tx_loginusertrack_pagestat.hits) FROM `tx_loginusertrack_pagestat` INNER JOIN fe_users on fe_users.uid = tx_loginusertrack_pagestat.fe_user WHERE page_id =82 AND fe_user = (SELECT uid FROM fe_users WHERE fe_users.tx_lsysfeusersimport_sales_rep_id = rep.rep_id) AND tx_loginusertrack_pagestat.tstamp > 1262307600),0) PORTALYTD, IFNULL((SELECT sum(tx_loginusertrack_pagestat.hits) FROM `tx_loginusertrack_pagestat` INNER JOIN fe_users on fe_users.uid = tx_loginusertrack_pagestat.fe_user WHERE page_id =82 AND fe_user = (SELECT uid FROM fe_users WHERE fe_users.tx_lsysfeusersimport_sales_rep_id = rep.rep_id) AND tx_loginusertrack_pagestat.tstamp > UNIX_TIMESTAMP(CONCAT(YEAR(NOW()),'-',MONTH(NOW()),'-','1 02:00:00'))),0) PORTALMTD, SUM(1) TOTALACCOUNTS, SUM(IF(u.tx_lsysfeusersimport_target1 = 999999999, 1, IF((ROUND((IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.year = YEAR(NOW())),0) / (u.tx_lsysfeusersimport_target1 * ((MONTH(NOW()) - 1) + ROUND(DAY(NOW()) / DAY(LAST_DAY(NOW())),2))) * 100),2)) > '100.00', 1, 0))) YTDTARGETACHIEVED, (SUM(1) - SUM(IF(u.tx_lsysfeusersimport_target1 = 999999999, 1, IF((ROUND((IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.year = YEAR(NOW())),0) / (u.tx_lsysfeusersimport_target1 * ((MONTH(NOW()) - 1) + ROUND(DAY(NOW()) / DAY(LAST_DAY(NOW())),2))) * 100),2)) > '100.00', 1, 0)))) YTDTARGETNOTACHIEVED, SUM(IF(u.tx_lsysfeusersimport_target1 = 999999999, 1, IF(ROUND((IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.month = MONTH(NOW()) AND s.year = YEAR(NOW())),0) / (u.tx_lsysfeusersimport_target1 * ROUND((DAY(NOW()) / DAY(LAST_DAY(NOW()))),2)) * 100),2) >= '100.00', 1, 0))) MTDTARGETACHIEVED, (SUM(1) - SUM(IF(u.tx_lsysfeusersimport_target1 = 999999999, 1, IF(ROUND((IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.month = MONTH(NOW()) AND s.year = YEAR(NOW())),0) / (u.tx_lsysfeusersimport_target1 * ROUND((DAY(NOW()) / DAY(LAST_DAY(NOW()))),2)) * 100),2) >= '100.00', 1, 0)))) MTDTARGETNOTACHIEVED, #u.company COMPANY, SUM(IF(u.tx_lsysfeusersimport_target1 != 999999999, (u.tx_lsysfeusersimport_target1 * ROUND((DAY(NOW()) / DAY(LAST_DAY(NOW()))),2)), IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.month = MONTH(NOW()) AND s.year = YEAR(NOW())),0))) MTDTARGET, SUM(IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.month = MONTH(NOW()) AND s.year = YEAR(NOW())),0)) MTDACTUAL, SUM(IF(u.tx_lsysfeusersimport_target1 != 999999999, (u.tx_lsysfeusersimport_target1 * ((MONTH(NOW()) - 1) + ROUND(DAY(NOW()) / DAY(LAST_DAY(NOW())),2))), IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.year = YEAR(NOW())),0))) YTDTARGET, SUM(IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.year = YEAR(NOW())),0)) YTDACTUAL, SUM(IF(u.tx_lsysfeusersimport_target1 = 999999999, 0, (IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.month = MONTH(NOW()) AND s.year = YEAR(NOW())),0) - (u.tx_lsysfeusersimport_target1 * ROUND((DAY(NOW()) / DAY(LAST_DAY(NOW()))),2))))) MTDVARIANCE, SUM(IF(u.tx_lsysfeusersimport_target1 = 999999999, 0, (IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.year = YEAR(NOW())),0) - (u.tx_lsysfeusersimport_target1 * ((MONTH(NOW()) - 1) + ROUND(DAY(NOW()) / DAY(LAST_DAY(NOW())),2)))))) YTDVARIANCE, ROUND(((SUM(IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.month = MONTH(NOW()) AND s.year = YEAR(NOW())),0)) / SUM(IF(u.tx_lsysfeusersimport_target1 != 999999999, (u.tx_lsysfeusersimport_target1 * ROUND((DAY(NOW()) / DAY(LAST_DAY(NOW()))),2)), IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.month = MONTH(NOW()) AND s.year = YEAR(NOW())),0)))) * 100),2) MTDPERCENT, ROUND(((SUM(IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.year = YEAR(NOW())),0)) / SUM(IF(u.tx_lsysfeusersimport_target1 != 999999999, (u.tx_lsysfeusersimport_target1 * ((MONTH(NOW()) - 1) + ROUND(DAY(NOW()) / DAY(LAST_DAY(NOW())),2))), IFNULL((SELECT SUM(value) FROM tx_lsysfeusersimport_sales s WHERE s.customer_account_number = u.tx_lsysfeusersimport_account_number AND s.year = YEAR(NOW())),0)))) * 100),2) YTDPERCENT FROM fe_users u INNER JOIN tx_lsysfeusersimport_sales_rep rep ON rep.rep_id = u.tx_lsysfeusersimport_rep_id INNER JOIN tx_lsysfeusersimport_regions reg ON reg.region_codes = rep.region WHERE u.usergroup = 2 AND u.deleted = 0 AND u.disable = 0 AND u.tx_lsysfeusersimport_target1 NOT LIKE 999999 AND u.tx_lsysfeusersimport_account_number > 0 AND rep.deleted = 0 AND rep.hidden = 0 AND reg.region_name NOT LIKE '' AND reg.region_codes IN (8) #AND reg.region_codes IN (1,2,3,4,5,6,7,8) #AND u.tx_lsysfeusersimport_rep_id = 874 GROUP BY REGION ORDER BY REGION LIMIT 0,60 EDIT: unfortunately though, this one proves the problem I asked about on a different thread earlier actually exists :-((( |
![]() |
![]() |
#12 |
|
Uhm, yeah just because you take a long SQL querry with zounds of nested selects won't make the language less simple... |
![]() |
![]() |
#13 |
|
LOL, the whole point of SQL is that it is simple. And of course you will find a true programming language more intimidating....what's your point? ![]() Also, I don't find a true programing language very intimidating, just assembly really... ![]() |
![]() |
![]() |
#14 |
|
Well you did just paste a huge SQL querry to show how intimidating it can look in it's non basic form, was simply a response to that. Your initial post seemed to imply that we don't tell OHP his post count in GD because we can't figure out a simple SQL statement |
![]() |
![]() |
#17 |
|
Iggie, did you know that you are messing with a PROJECT MANAGER? Did you see that SQL string? Holy ****... super cool d00d. Just saying... |
![]() |
![]() |
#18 |
|
|
![]() |
![]() |
#19 |
|
|
![]() |
Reply to Thread New Thread |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|