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…
Tag: sql-server-2005
SQL Query to determine number of tables
I have this table and I’m trying to determine how many Tables (in a restaurant) are awaiting food. The table( in the database) has the following columns: TableNumber, ObjectType, ObjectDescription and Quantity (amongst others). I made this query to see what is ordered, but would like to know how many un…
SQL SERVER – GRAB RECORD FROM THE TABLE BASED ON COLUMN ID
I have a db with records like the following structure in the table; I have and entire db set up like this where the fid in some cases matches the id of another record. In that case id like to return one record with 2 different dates such as ; I was thinking a self join but got hung up
Matching on Values, but Erroring on New Value in SQL Server
I am comparing data from two different databases (one MariaDB and one SQL Server) within my Node project, and am then doing inserts and updates as necessary depending on the comparison results. I have a question about this code that I use to iterate through results in Node, going one at a time and passing in …
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 …
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 sho…