Why do I get an error from this sub query script?

This is what your actual query is SELECT effectiveDate, CASE WHEN note=”REGULAR LOGGED” THEN log END FROM schedules LEFT JOIN timesheet ON schedules.effectiveDate = timesheet.date WHERE schedules.empid=’40’ AND YEAR(effectiveDate) = YEAR(CURDATE()) AND MONTH(effectiveDate) =’1′ GROUP BY effectiveDate. Not sure why you’re using a subquery

Counts on Changed data

Try this: SELECT CONCAT(‘Change from ‘, OrgMatch, ‘ to ‘, ReMatchConfidence) AS Data, Count(IF(Date=”2017″, 1, NULL)) as ‘2017’, Count(IF(Date=”2016″, 1, NULL)) as ‘2016’ FROM tables GROUP BY OrgMatch, ReMatchConfidence;

Is it possible to write single query on two table which are not connected to each other?

A Cartesian join (note there is no JOIN condition). All possible combinations of records are in the results: tableA (charfield Char(2)) tableB (numberfield Number(1)) INSERT ‘A’ INTO tableA; INSERT ‘B’ INTO tableA; INSERT 1 INTO tableB; INSERT 2 INTO tableB; SELECT * FROM tablea CROSS JOIN tableb Results: charfield|numberfield ===================== A |1 A |2 B … Read more

SQL Query To Create View [closed]

CREATE VIEW EmpList AS SELECT a.id_user, b.category_province_content, c.category_city_content, d.category_job_content FROM user_detail a INNER JOIN category_province b ON a.detail_province = b.id_category_province INNER JOIN category_city c ON a.detail_city = c.id_category_city INNER JOIN category_job d ON a.detail_job = d.id_category_job To further gain more knowledge about joins and MySQL views, kindly visit the links below: Visual Representation of SQL … Read more

Convert text to system date format [duplicate]

EDIT From SQL Server 2012 and later you might use the FORMAT function if you want to force a date into a formatted text: https://msdn.microsoft.com/en-us/library/hh213505.aspx With earlier versions you might use something like this: DECLARE @d DATETIME=GETDATE(); DECLARE @TargetFormat VARCHAR(100)=’DD/MM/YYYY’; SELECT CONVERT(VARCHAR(100),@d, CASE @TargetFormat WHEN ‘MM/DD/YYYY’ THEN 101 WHEN ‘DD/MM/YYYY’ THEN 103 –add all formats … Read more