创建一个SQL查询以选择不同的记录 [英] creating a sql query to pick distinct records

查看:90
本文介绍了创建一个SQL查询以选择不同的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好用户,
我必须在sql server中创建Querry.
有一个具有列
的表用户名 1.用户名
2.date
我必须找到从当前日期起2天没有在他的表中输入记录的记录.
条件是不能重装记录

hello users ,
i have to create a querry in sql server .
there is a table user name having column
1.username
2.date
i have to find the record that has not enterd records in his table from 2 days of current date.
condition is record sholud not be repited

推荐答案

从表中选择与众不同的用户名
select distinct(username) from table


可以使用 DISTINCT 避免重复记录&您可以使用 DATEADD()与SELECT语句一起操作以获取日期值.
我已经提供了示例查询,请根据需要编写自己的内容
You can use DISTINCT to avoid duplicate records & you can use DATEADD() to manipulate with your SELECT statement for Date values.
I have given Sample query so write yourself for your need
SELECT  DISTINCT(UserName) FROM TableUser WHERE [Date] < SELECT DATEADD(DAY,1,GETDATE())


这篇关于创建一个SQL查询以选择不同的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆