Skip to content

Tag: sql

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…

SQL – get an AVG from a COUNT

how you doing? I’m trying to get the average from a count. The metric is a string, so I get an error. I’ve tried some ways, but I can’t. Thanks for your help This is the code This is what I’ve unsuccessfully tried AVG (newsletter) as percentage AVG (CAST (newsletter as INT64)) as perce…