Skip to content
Advertisement

Get Row value as Column Header

I have two tables as below. I want to join these two tables and need to set the column values of second table as column header as shown below. How can I achieve this? Table1  table2 The output table should be Answer You can use Dynamic Pivot as below-

“Distinct” results in complex query

I have the following query, which returns all merchants in the database who have transactions between two given dates. But, there is additional information I need to include in the query. I’ve written the enhanced query below, but it results in duplicated merchants. I know the query could be written better, but that’s the limit of my SQL knowledge. I

SQL Joining of Multiple Tables

SQL newbie here, I am trying to have the table print out the sum of the wages, make, and car model for all the people that own a particular make/model combination. As of right now, the table prints …

C# application with SQL Server stored procedure

My C# Windows form has a combobox and textbox. The combobox has 2 records which are ‘Novel’ & ‘Poem’. I need to write code that if I select ‘Poem’, it should be auto generate ‘PO-00001’ and if I select ‘Novel’, it should be auto generate ‘NV-00001’. So then I wrote a stored procedure to do that and it looks like

SQL Query to get 2nd most recent results with multiple columns

I am trying to obtain the 2nd most recent results for all distinct part_id’s(based off of order_date) to go into a report I am working on making to compare it to the most recent results. The commented sections are from another approach I was trying but unsuccessful with. Any help is greatly appreciated! (Side note: I am new to posting

Count the number of appearances of char given a ID

I have to perform a query where I can count the number of distinct codes per Id. The output should be something like: Can you give me some advise on this? Answer If the codes are only to the provided ones, the following query can provide the desired result. Note: as I can see from sample input data, code ‘I’

Advertisement