[Solved] Concatenate ‘A’ with SQL query

Try following if your implementation is in SQL Server. SELECT tblgrade.fld1stGrade +’A’ FROM tblgrade WHERE CAST(tblgrade.fld1stGrade as int) >= 90 and cast(tblgrade.fld1stGrade as int) <= 99; For MySQL implementation use following. select concat(tblgrade.fld1stGrade, ‘A’) from tblgrade where tblgrade.fld1stGrade >= 90 and tblgrade.fld1stGrade <= 99; For multiple category comparison in MySQL, use something like below. select … Read more

[Solved] SQL SELECT statements – different number of columns

An union is a mathematical operation between sets. This kind of operations requires the two tables to be COMPATIBLE, which means that they have to have the same columns in number and types. And it’s clearly obvious that you’re trying to make an union between a 3 columns SELECT and 1 column SELECT statements (the … Read more

[Solved] I am trying to create a sql table in phpmyadmin, I’m getting 4 errors. This code works in phpmyadmin on my pc at my work but not on the pc at home [closed]

I am trying to create a sql table in phpmyadmin, I’m getting 4 errors. This code works in phpmyadmin on my pc at my work but not on the pc at home [closed] solved I am trying to create a sql table in phpmyadmin, I’m getting 4 errors. This code works in phpmyadmin on my … Read more

[Solved] Variable Declaration [closed]

Collect your error messages, if you get none return the result of your query, else return or raise the collected errormessages. Declare @a Table (a int,b int,c int) insert into @a Values(1,2,3),(4,4,4) Declare @va int=2 Declare @vb int=2 Declare @vc int=2 Declare @error Varchar(100)=” if not exists(select * from @a where a=@va) Select @Error=@Error + … Read more

[Solved] COUNT and GROUP BY doesn’t works as expected [closed]

What exactly you want to count? Only consumed? Or consumed by goal? If the second option, you need group by statment. SELECT count(consumed) as count FROM (some select) alias Or SELECT count(consumed) as count, goal FROM (some select) alias Group by goal solved COUNT and GROUP BY doesn’t works as expected [closed]

[Solved] Separate a value from string in SQL Server 2012 [duplicate]

create the UFN_STRING_SPLIT function suggested by @Dave here link create FUNCTION [dbo].[UFN_STRING_SPLIT] ( @List NVARCHAR(MAX), @Delimiter NVARCHAR(255) ) RETURNS TABLE WITH SCHEMABINDING AS RETURN ( SELECT Item = y.i.value(‘(./text())[1]’, ‘nvarchar(max)’) FROM ( SELECT x = CONVERT(XML, ‘<i>’ + REPLACE(@List, @Delimiter, ‘</i><i>’) + ‘</i>’).query(‘.’) ) AS a CROSS APPLY x.nodes(‘i’) AS y(i) ); test your code: … Read more

[Solved] Insert into Temp Table from SQL Dynamic Results

all what i had to do is add this: ‘ into ##myTempTable DECLARE @DynamicPivotQuery AS NVARCHAR(MAX) DECLARE @ColumnName AS NVARCHAR(MAX) –Get distinct values of the PIVOT Column SELECT @ColumnName = ISNULL(@ColumnName + ‘,’,”) + QUOTENAME([month]) FROM (SELECT DISTINCT [Month] FROM MyTable) AS [Month] order by [month] –Prepare the PIVOT query using the dynamic SET @DynamicPivotQuery … Read more