Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

select

$
0
0

Hi,

I have a table with columns clientid,name ,statdate ,enddate...

in my project i have two application which are using same table .

In application1  user dont have cleint ID .in application2 user have id which is default.

below is the query to retieve all distinct empid's ,it returns all id's

select distinct EmpID,EmpName,StartDate,EndDate from EmpTimesheet order by EmpID .

If i want to select only distinct EmpID,EmpName,StartDate,EndDate from EmpTimesheet  and who dont have clientid =null

CREATE TABLE [dbo].[EmpTimesheet](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ClientID] [int] NULL,
	[EmpID] [int] NOT NULL,
	[EmpName] [varchar](50) NULL,
	[StartDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	) ON [PRIMARY]

clientid  id 	name      sd                       enddate

32 6 abc 2014-02-09 00:00:00.000 2014-02-15 00:00:00.000 Thurs 2014-02-13 00:00:00.000

32 6 abc 2014-02-09 00:00:00.000 2014-02-15 00:00:00.000 Fri 2014-02-14 00:00:00.000

NULL 8 test 2014-02-02 00:00:00.000 2014-02-08 00:00:00.000 Sun 2014-02-02 00:00:00.000

NULL 8 test 2014-02-02 00:00:00.000 2014-02-08 00:00:00.000 Mon 2014-02-03 00:00:00.000



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>