I am trying to run a query in SQL Server where the columns I select are different than how it is grouped. This query is used in SAP Business One.
The problem, is that if I group by all the same columns that are selected, nothing is grouped.
Here is my query (which will obviously not work).
SELECT
T0.[CardCode], T2.[SlpName] as 'Rep',
T0.[CardName] as 'Facility',
T1.[Address] as 'Attention',
T1.[Street] as 'Address 1',
T1.[Block] as 'Address 2', T1.[City] as 'City',
T1.[State] as 'State',
T1.[ZipCode] as 'Zip'
FROM OCRD T0
INNER JOIN CRD1 T1 ON T0.[CardCode] = T1.[CardCode]
INNER JOIN OSLP T2 ON T2.[SlpCode] = T0.[SlpCode]
WHERE T1.[State] = 'FL'
GROUP BY T0.[CardCode]
Any feedback would be appreciated.
Thanks,