嗨,我爲數據創建一個存儲過程,併發送推送notification.and我想這些數據marge並獲得一個原始。但我怎麼能這樣做,我不知道。我需要幫助,請幫助我,讓我知道該怎麼做that.this是我在這裏查詢下面我有寫:如何使用sql server從表格中查找數據?
這是查詢=>
SELECT N.NotificationId,
N.UserId,
N.ActionUserId,
(CASE WHEN N.NotificationTypeId = 1 THEN 1
WHEN N.NotificationTypeId = 7 THEN 3
ELSE
2
END) AS TypeId,
AU.ProfileImage,
AU.UserName,
N.IsRead,
(CASE WHEN N.NotificationTypeId = 1 THEN 1
WHEN N.NotificationTypeId = 7 THEN 3
ELSE
2
END) AS TypeId,
N.NotificationTypeId,
N.InsertDateTime
FROM Notifications N
INNER JOIN Users U ON N.UserId = U.UserId
INNER JOIN Users AU ON N.ActionUserId = AU.UserId
ORDER BY N.InsertDateTime DESC
這是我目前的O/P =>
NotificationId | UserId | ActionUserId | UserName | NotificationTypeId | InsertDateTime | ProfileImage
6 20 15 hbc 1 2017-06-22 17:14:16.803 20170416032403869.jpeg
5 20 16 tyu 1 2017-06-22 17:12:12.297 20170416031522534.jpeg
4 20 17 opl 1 2017-06-22 17:11:58.060 20170416031250102.jpeg
3 10 11 abc 1 2017-06-22 16:14:16.803 20170416032403867.jpeg
2 10 12 xyz 1 2017-06-22 16:14:12.297 20170416031522533.jpeg
1 10 13 rty 1 2017-06-22 16:13:58.060 20170416031250101.jpeg
這是我預期的O/p =>
NotificationId | UserId | ActionUserId | UserName | NotificationTypeId | InsertDateTime | ProfileImage | NotificationText
6 20 15 hbc 1 2017-06-22 17:14:16.803 20170416032403869.jpeg hbc,tyu and 1 other users followed you
3 10 11 abc 1 2017-06-22 16:14:16.803 20170416032403867.jpeg abc,xyz and 1 other users followed you
我想喜歡這種瑪吉這個數據的任何一個知道如何能做到這一點認罪讓我知道。
您的輸出結果與您的查詢不匹配... – iamdave
我知道NotificationText列未在查詢中提及,但它是我的預期o/p – coderwill
Where Insert DateTime'來自例如? – iamdave