A file supplied by a Client has the following structure: FullName Mr John Joe Smith They would like this transformed to the following: Salutation FirstName MiddleName LastName Mr John Joe Smith I’ve looked into this and I’ve tried the following: This produces: Salutation FirstName Mr John Joe Smith I’m struggling to separate it further, is this the best way of
Tag: sql-server
SQL Query to Find if (Count of date > X) = 0 For Group of ID
I apologize if the title is not be correct as I’m not sure what I need to ask for, since I don’t know how to build the query. I have the following query built to return a list of chemicals and other related fields. I am using this query in a VB.Net application where it exports the results to an
Calculate amount of days worked by employee from 1 column to another with a function
This is my function I have so long, I need to be able to just call it with with an Employee number from the Employee table and it has to calculate the days between the 2 columns. If there is a better way please let me know, this is what I have… Answer Presumably, you want something related to the
Running count SQL server
Can someone please help me in counting the rows in SQL Server Expected result Answer Try this:
Dynamic SQL mistakenly looks for table variable
my code accepts table name parameters and my dynamic code is supposed to query a table. I consistently get the error: @sourcetbl variable must be declared. After a lot of troubleshooting, I realized …
group by category to show difference by month in SQL
I have a view that brings the total number of members in each class for each month however I want to show the growth by subtracting the total_count of the previous month with the current month in a separate column. For example, I would like to view the data as mentioned in the attached image. Here on that table, you
How do I get two different counts from a table in select query
I am trying to have my select query pull the count of items that exist in both tables in one column, and the count of the items that only exist in one table. These two queries give me the data I need, but would like it come from one query. Thanks in advance. Desired Result: Answer You can combine a
Pivoting rows to columns with custom column names in SQL Server
I’m having some difficulty with pivoting rows into columns as I also want to name the columns. Here is my current code, modified: And my current output: Just for the sake of shortness, I replaced the actual Message with longmessage1 above. My desired output: The maximum amount of greetings is six, and if a Message doesn’t have six, I’m fine
Percentage in SQL Server
I want to find the percentage between two columns and I tried this : select (count(id)* 100.0 /(select count(id) FROM db.table where log = ’40’)) as percentage from db.table; And the result is this: …
How to split data in SQL
I have the following code: Used Table names: WIPtransaction, WIPtransactiontype, Feeearner I want to display two more columns at the end of the output, namely: Invoiced and Uninvoiced. The “Invoicenumber” field in the “WIPtransaction” database will be tested for this. If the “Invoicenumber” is NULL – the transaction amount will be added to a sum in the uninvoiced column and