Suppose i have following coloumn
|
AppointDateTime
01-15-2019 21:14:12
|
| 01-16-2019 12:05:13 |
| 01-16-2019 12:55:47 |
| 01-16-2019 17:25:00 |
| 01-16-2019 18:19:20 |
| 01-17-2019 05:18:30 |
Now I want to soterd data according to date and as well as time
| 01-16-2019 12:05:13 |
| 01-16-2019 12:55:47 |
| 01-16-2019 17:25:00 |
| 01-16-2019 18:19:20 |
| 01-17-2019 05:18:30 |
01-15-2019 21:14:12
So how can i do this
Following is my query
USE [docprimenew]
GO
/****** Object: StoredProcedure [BMS].[GetAgentDashboardDetails] Script Date: 01-16-2019 15:47:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [BMS].[GetAgentDashboardDetails]
(
@ProductID Smallint = null,
@Leads [BMS].[LeadTable] READONLY
)
AS
BEGIN
SET NOCOUNT ON
SET DEADLOCK_PRIORITY LOW
Select * from (
SELECT Distinct
LD.LeadID,
LD.Name,
LD.EmailId,
--STUFF(LD.MobileNo, 1, 6,'******') AS MobileNo,
cast (LD.MobileNo as varchar(50)) AS MobileNo,
LD.CustomerID,
LD.LeadSource,(cast(isnull(CCBD.CallBackDate,'') as datetime)+isnull(CCBD.StartTime,'')) as CallBackDate,
LD.CreatedOn,
LD.UpdatedOn as 'StatusDate',
ZC.City,'Consumer' as ProductName,
Ld.ProductID ,
bd.BookingDateTime as OffercreatedOn,
0 as OfferNumber,
SM.StatusName,
Bd.AppointmentDatetime as AppointmentdateTime,
0 as CustIdentityID
-- ,cast([BMS].[CheckTwoDatesDifference](Bd.DocPrimeBookingID) as varchar(100)) as Time
FROM @Leads AS L
INNER JOIN prime.AppointmentDetails BDWITH(NOLOCK) ON L.LeadID=BD.LEADID and bd.IsActive=1
INNER JOIN CRM.Leaddetails LDWITH(NOLOCK) ON L.LeadID=LD.LeadId
left join BMS.CustomerCallBackDetails CCBD WITH(NOLOCK) ON L.LeadID=CCBD.LeadId and CCBD.IsActive=1
INNER JOIN CRM.LeadStatus LSWITH(NOLOCK) ON L.LeadID = LS.LeadID AND LS.IsLastStatus=1
INNER JOIN CRM.Statusmaster SMWITH(NOLOCK) ON SM.StatusID = LS.StatusID and SM.IsActive=1
LEFT JOIN import.zonecities ZCWITH(NOLOCK) ON ZC.CityID=LD.CityID
)
--as a ORDER BY OffercreatedOn DESC
as a ORDER BY AppointmentdateTime
END

Manoj BhoirPosted May 9, 2019, 1:02 AM
Shraddha PatelPosted May 8, 2019, 11:24 PM
Syntax:
SELECT * FROM table_name ORDER BY column_name ASC|DESC
table_name: name of the table.
column_name: name of the column according to which the data is needed to be arranged.
ASC: to sort the data in ascending order.
DESC: to sort the data in descending order.
| : use either ASC or DESC to sort in ascending or descending order
Syntax:
SELECT * FROM table_name ORDER BY column1 ASC|DESC , column2 ASC|DESC
Munesh SharmaPosted Feb 1, 2019, 6:51 AM
Shahriar NikkhahPosted Jan 27, 2019, 7:44 PM
Jignesh KumarPosted Jan 16, 2019, 9:43 AM
Kapil GaurPosted Jan 16, 2019, 7:58 AM
Navjot AngraPosted Jan 16, 2019, 7:29 AM
Kapil GaurPosted Jan 16, 2019, 7:24 AM