Question: I am querying some data from the database, and my code looks as below

```
select 
a.id
a.party
a.date
a.name
a.revenue
b.company
c.cost 
from a
left join b on a.id = b.id
left join c on a.id = c.id
where a.party = 'cat' and a.date > '2000-01-01'

```

I got a returned table but the table has duplicated rows. Is there anyway I can remove all duplicated rows (meaning the entire row is the same, row 1 = row2, remove row1)

I put `select distinct` at the top, but then it took forever to run. Not sure if some fundamental programming logic was wrong in this code.

Answer: 
SQL Server has two functions, depending on whether you want a string or a number:

```
[datepart(weekday, col)][1]
[datename(weekday, col)][1]

```

You can also use `format()` with the `'dddd'` specification:

```
format(col, 'dddd')

```

This is convenient, because `'ddd'` gives you a three-letter abbreviation. And `format()` allows a third argument where you can specify the culture -- such as enforcing that the value is in English.
Below should do. The parameter should be slightly different from `datepart`. Use `W` instead of `week`

```
select datename(W, '2020-02-02' ) 

```