Using the example below, (from the answer in this link here) how can I select/group with an extra column ? I have searched this site and others and tried some examples but couldn’t get it to work. Answer It sounds like what you want would be: Then in the .Select() This groups on distinct combinations of rate class and vehicle
Tag: sql-server-2005
Salesforce Marketing Cloud SQL PIVOT
I’m trying to create a pivot in SFMC to combine multiple rows into one column. The query is running successfully, but not populating correctly. My table has 2 columns: email address and product_sku. …
Build combined table from 2 uneven tables
I have 2 uneven tables which I am trying to build into 1 table, each table has a date and ID to join with, the issue is that sometime 1 table can have rows with no matching date in 2nd table Initially table 2 seemed to always have an entry for table 1 so I was doing a left join
My script has no effects in more than 3 rows
The script works fine when it has 2 rows. Stop reading from 3. This is MSSQL Server 2005. Try anyway without any result. There is no error message. But if I have more than 10 rows, it doesn’t affect the row that should affect. Answer Given the new information in your comment you should simplify this to an update statement.
How to update last record with second lat results [SQLServer]
I want to update the last entry of the table with Pass/Fail result from the second last row. And the query need to didnt fail if only one row is in the table. Here is the code what i have, but ist …
SQL Updating column after adding it giving “Invalid column name” error
I have the following SQL in SQL Server 2005 but I get an error stating “Invalid column name ‘ExpIsLocalTime’ (ln 7) when I run it: IF NOT EXISTS(SELECT * FROM sys.columns WHERE Name = N’…
Update and insert to one table from another
I have two tables: table1: (ID, Code, Name) table2: (ID, Code, Name) with same columns I want to to insert data from table1 to table2 or update columns if that exists in table2 (table1.ID = table2.ID) What is the simple way to do this? WITH OUT MERGE Answer There are some issues with Merge statement,so it should be used with
Compare two time strings in SQL
I have a string variable that denotes a time: I need to check if the current time getdate() is after or before @time. How can I do this in SQL? Answer This should do it: SQL 2008+ Earlier:
How to convert a varchar column to bit column in SQL SERVER
Flag1 is a varchar column with values “true” and “false”. I need to convert this into bit column. When I try to do this: Convert(Bit,Flag1) it shows an error Msg 245, Level 16, State 1, Line 2 …
Add/remove columns of a table – code maintenance / optimisation
What is the best way to maintain code of a big project? Let’s say you have 1000 stored procedures, and you have to add a new column to a table (or remove) There might be 1-2 or 30 stored procedures, that might be affected. Just a single “search” for the tablename might not be good enough, let’s say you only