Skip to content

How to count from first date till date?

I have a table like below in SQL server Date Store ID Sales Amount 01-01-2021 1001 1000$ 01-01-2021 1002 1000$ 01-01-2021 1003 0$ 02-01-2021 1001 1000$ 02-01-2021 1002 1000$ 02-01-2021 1003 1000$ 03-01-2021 1001 1000$ 03-01-2021 1002 1000$ 03-01-2021 1003 1000$ how to calculate count of previous days if Sales…

sum of value based on a category

I want to print the total sum of categories in every row using my-SQL and I am not able to do it can anyone please help me, example: store region sales 106 Atlanta 250000 107 Atlanta 300000 108 …

Insert repeating tag xml data to multiple sql table columns

I’m having following XML and query. header tags are there and Item tag can be repeated up to 10 tags. I want to insert those item no and qty in separate columns. Here I mentioned only 2 tags for Item but in real situation there are 5 tags in XML. So in worst case scenario it will be 50 columns.

Select average entries per day into table

Ok I have looked at multiple entries in stackoverflow for this but cant seem to quite work them for me. I have a table called email_Archive It contains every email sent by every user. Columns in Db are: Challenge: I am trying to get the average amount of emails sent by a select list of users per day for the

Divide by zero exception in SQL Server

I have an update statement which has division operation and one row throws exception Divide by zero exception and I see that none of the rows got updated . How to continue on exception so that rows which doesn’t encounter 0 gets updated and row which has 0 fails? Its just a normal update statement witho…