Viewing 15 posts - 781 through 795 (of 2,648 total)
Can you explain what you are trying to do with the query?
You cannot return two values fin the THEN and you also cannot OR two strings together ( THEN 'Midwest'...
November 5, 2021 at 1:46 pm
I don't understand what you are trying to do or your data. But I think the part:
Bank = (Select Bank From Customer Where Customer=t.Customer)
is redundant.
I think this...
November 4, 2021 at 10:56 pm
select 'Midwest' OR 'Mid-Atlantic'
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'OR'.
Completion time: 2021-11-04T21:11:04.2830349+00:00
November 4, 2021 at 9:11 pm
IF OBJECT_ID('tempdb..#PartTransactions','U') IS NOT NULL
DROP TABLE #PartTransactions
GO
SELECT *
INTO #PartTransactions
FROM (VALUES ('2020-12-31 19:00:09',3,7000917),
('2020-09-29 12:05:25',1,7000917),
... November 3, 2021 at 7:41 pm
the 'x' was just there so it's included in the count. You could put anything that's not null.
This is also the equivalent:
SELECT pt.[imtPartID],
...
November 3, 2021 at 5:52 pm
I think this might be what you want:
SELECT pt.[imtPartID],
COUNT(CASE WHEN pt.[imtPartID] = 1 THEN 'x' ELSE NULL END) AS Receipt,
...
November 3, 2021 at 5:38 pm
I can't see that your query will work?
You are missing a bracket after PIVOT.
If you could supply your input data and the output expected it would be easier to understand.
November 3, 2021 at 5:35 pm
CREATE TABLE [dbo].[tblClientService]
(
[ID] [int] IDENTITY(1,1) NOT NULL,
[ClientID] ...
October 30, 2021 at 2:23 am
Thanks Jeff,
Good so see the function is in use. It does make your code much shorter than other methods.
October 27, 2021 at 9:23 am
Data type disparity on join conditions etc is not really an after thought I've seen over time, its more like a 'no thought.' You bring up an excellent point...
October 24, 2021 at 6:46 pm
I think the functions TRY_CAST, TRY_CONVERT and TRY_PARSE might be of use.
October 21, 2021 at 11:26 pm
I think OUTER APPLY is the way to go.
Here is another way to write it, also using OUTER APPLY:
SELECT p.PatID,
...
October 11, 2021 at 11:01 am
This should work
SELECT w2.RCWHS# ...
October 8, 2021 at 2:37 pm
Another method
select *
from #temp t
where t.Branch = 'head quarters'
union all
select *
from #temp t
where not exists(select *
...
October 7, 2021 at 11:00 am
;with cte as
(
select distinct t.Id
from #temp t
)
select t.*
from cte x
cross apply(select top(1) *
...
October 6, 2021 at 12:05 am
Viewing 15 posts - 781 through 795 (of 2,648 total)