SQL server 2012 I am taking fees received and multiplying them by different factors based on how long the Client has been a Client. The group by clause is fairly straight forward. However, my select gets awkward when I want to use this criteria in different ways: I suppose I should mention this is a simplified version of my actual
Tag: tsql
Change the format of joining date to month-day,year sql
Change the format of joining date to month-day,year for e.g. January 31,1992. Query Error Table emp_demo format Answer You seem to be looking to display your date in a given format (which is what to_char() does in Oracle). In SQL Server, you can use format(): Demo on DB Fiddle: Yields:
Creating a Pivot Table in SQL
I could use some help with creating a PIVOT table. The table that I’m looking to pivot from is: Where I want to change it into the Format of Which has the tracking number as the Row Identifier, the added columns are the Unique Values in the ‘Surcharge Reason’ column, and the values of the data are the Surcharge Amount
SQL bring number of count, another column basis problem [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have this table: BANK – BRANCH_NAME – ADDRESS – DISTRICT – CITY – PHONE – FAX – OPENNING DATE How do I bring branches
Fill in missing dates and grouping problem
I have a table with Case records with CaseId, UserId, Opened date, Closed date etc value. For reporting I need to have a result table with all users by continuous months with number of case still …
Sum rows not in the top x rows of a group in the table into an “other” row?
If I have a table like the following which is the number of records with a given label grouped by a certain category (in this case Male, Female), How would I transform it into a table that keeps the top x (e.g. 5 records) for each category, when the rows are sorted by number descending, and sums the remaining rows
SQL Query to categorize results of separate query
I am trying to run a query on the results of a separate query to update the Route_Type column for each record based on unique Route_Code and Delivery_Day. For each distinct Route_Code from the select …
Comma-separated values to rows with sum in SQL Server
Output: I want to convert the output to this format: i.e. comma-separated all the orgs and sum of it’s area value. Answer Sub-query is really not necessary :
Select statement: Invalid column name, in C# using Dapper [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 6 months ago. Improve this question
SQL – Select with group by, Get data from the register with the max(date)
I have two tables in the database: Product and ProductVersion , each product can have n ProductVersions. ProductVersion has this fields ( Id, name, origin, date, provider ) I want a query where I get …