Viewing 15 posts - 1 through 15 (of 1,438 total)
Can you post the actual question that you asked it? I'm curious as to how much it needed to know.
Literally all of the original question starting with "I have...
February 6, 2023 at 6:42 pm
Just for fun I tried cutting and pasting the original question into ChatGPT, this is what it came up with. As far as I can tell it works.
You can use...
February 6, 2023 at 11:07 am
Something like this?
WITH GroupedNational_Identity AS (
SELECT uniqueid, natid_type, STRING_AGG(natid_num,'|') AS natid_num, active, individual_list_id_fk
FROM national_identity_test
GROUP BY uniqueid, natid_type, active, individual_list_id_fk
)
SELECT 'CNIC' as ID_TYPE_01,
MAX(CASE WHEN NatID_Type = 'CNIC'...
December 15, 2022 at 10:08 am
Use ISNULL
SELECT ISNULL(
(SELECT 'CNIC' as ID_TYPE_01,
MAX(CASE WHEN NatID_Type = 'CNIC' THEN NatID_Num END) AS ID_NUMBER_01,
'PASSPORT' as ID_TYPE_02,
...
November 30, 2022 at 11:23 am
This should work for you
SELECT 'CNIC' as ID_TYPE_01,
MAX(CASE WHEN NatID_Type = 'CNIC' THEN NatID_Num END) AS ID_NUMBER_01,
'PASSPORT'...
November 30, 2022 at 8:36 am
Duplicate deleted
November 15, 2022 at 5:00 pm
Try this
s.PO.value('(/UserArea/Property/NameValue[@name="ManufacturerPart"])[1]', 'nvarchar(50)') as MFG
November 15, 2022 at 4:59 pm
I'm not really clear about how the data fits together, but this query matches your expected results.
This is for a fixed number of approaches, if you want this to be...
October 12, 2022 at 9:49 am
This should handle multiple channels
SELECT device.DeviceSerialNumber,Readings.ChannelId,Readings.DataHashDto,
channel_list.Si,channel_list.Raw,channel_list.Conversion,channel_list.TimeStamp
FROM OPENJSON(@json)
WITH
(
ChannelReadings NVARCHAR(MAX) '$.ChannelReadings' AS JSON,
DeviceSerialNumber NVARCHAR(100) '$.DeviceSerialNumber'
) AS device
OUTER APPLY OPENJSON(device.ChannelReadings)
WITH
(
ChannelId INT '$.ChannelId',
DataHashDto NVARCHAR(MAX)...
October 6, 2022 at 8:01 pm
Just remove the 'order by'
select t.* from (
select a.Dept,SUM(t.Amount) AS Amount
from TableA a
outer apply(select top 1 b.Amount
...
September 28, 2022 at 1:55 pm
Try this
select a.Dept,SUM(t.Amount) AS Amount
from TableA a
outer apply(select top 1 b.Amount
from TableB b
where b.CustNo =...
September 27, 2022 at 3:52 pm
select a.CustNo,t.Amount
from TableA a
outer apply(select top 1 b.Amount
from TableB b
where b.CustNo = a.CustNo
order by abs(datediff(day,a.[Date],b.[Date])))...
September 27, 2022 at 2:01 pm
declare @mytable table(mydata nvarchar(max));
insert into @mytable(mydata)
values(N'
{
"_Journals": [
{
"SourceType": 18,
"JournalID": "sdfdsf-fdfs-dfdf-dfdfd-dfdsfsfdd",
"SourceID": "sdfsdf-sdfds-sdf-dfd-sdfsdf",
"JournalLines": [
{
"AccountType": 3,
"JournalLineID": "sdfsdfsd-sdfsdf-sdfsd-sdfsdf-sdfsdf",
"TaxName": "Some tax name",
"TrackingCategories": []
},
{
"AccountType": 3,
"JournalLineID": "sdfsdfsdf-sdfsdf-sdf-sdf-sdf",
"TaxName": "text",
"TrackingCategories": []
}
]
},
{
"SourceType": 18,
"JournalID": "sdfsd-sdfd-sdfd-sdf-dfdsfd",
"SourceID": "61da35a7-4f8c-4d3a-9a18-e531734b419c",
"JournalLines": [
{
"AccountType": 3,
"JournalLineID": "sdfdsf-dsfds-sdf-sdfsd-sdfd",
"TaxName":...
September 19, 2022 at 10:46 am
This, I think
SELECT 'Class1' AS "@ClassName",
'String' AS "ExternalId/@TYPE",
AccountNumber AS "ExternalId"
FROM #Account
FOR XML PATH('Element'),TYPE;
September 7, 2022 at 7:37 pm
Try this
with cte as (
select AccountId,Values_1,Time_1,Designation,
lag(Values_1) over(partition by AccountId order by Time_1) as PrevValues_1
from DataTable
)
select AccountId,Values_1,PrevValues_1,Time_1,Designation,abs(Values_1 - PrevValues_1) as Diff
from...
September 6, 2022 at 7:54 am
Viewing 15 posts - 1 through 15 (of 1,438 total)