Skip to content

Tag: sql-server

Multiplying 2 column values in Dynamic SQL

This is giving the error message: Conversion failed when converting the varchar value ‘27.72081’ to data type int. Answer You’re casting numeric values to VARCHAR inside your dynamic statement. Remove the CASTs and it should be good. Your resulting statement should read something like this w…

How to get row count based on other column groups

I need to count the number of dates with which the invoices are made to certain customers in each month Consider the table named Table1 I tried the folllowing code and the result was The result I need should count the column named branch based on column month, the desired result is Here rowcount is based on b…