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

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

SQL query for salary in emp table

You’ll have to get the percentage of the year worked and multiply it by the salary. If the joined_date is before January of that year, use ‘1.00’. Since you did not specify a SQL type, I chose MSSQL as I’m most familiar with it. Here’s an example using MSSQL: DECLARE @yearToFindSalaryFor INT = 2018 DECLARE … Read more