I want to select that rollnos which have distinct name & address.
create table studento(roll int,name varchar,address varchar(5))
insert into studento values(1,'A','ADD1')
insert into studento values(2,'B','ADD2')
insert into studento values(3,'A','ADD3')
insert into studento values(4,'A','ADDR3')
select name from studento
I have tried the foll. query to retrive the roll that has distinct name,But query is still returning all roll numbers.
select roll from studento where name = (Select distinct(name)
from studento) 3 1764
Hi Yogesh
But all of those records that you show do have a distinct name and address
also this query -
select roll from studento where name = (Select distinct(name)
-
from studento)
-
should generate a "subquery returned more than 1 value" error
because there are 2 distinct names
I want to select that rollnos which have distinct name & address.
create table studento(roll int,name varchar,address varchar(5))
insert into studento values(1,'A','ADD1')
insert into studento values(2,'B','ADD2')
insert into studento values(3,'A','ADD3')
insert into studento values(4,'A','ADDR3')
select name from studento
I have tried the foll. query to retrive the roll that has distinct name,But query is still returning all roll numbers.
select roll from studento where name = (Select distinct(name)
from studento)
In your example, which roll will you choose for name A?
If you're choosing the first one, try this: - select name,min(roll) as roll from studento
-
group by name
You may also take the name column from the SELECT list.
-- CK
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Florian |
last post by:
Hi,
I have a table that contains log data, usually around a million records. The
table has about 10 columns with various attributes of the logged data,
nothing special. We're using SQL Server...
|
by: Rich |
last post by:
My table looks like this:
char(150) HTTP_REF,
char(250) HTTP_USER,
char(150) REMOTE_ADDR,
char(150) REMOTE_HOST,
char(150) URL,
smalldatetime TIME_STAMP
There are no indexes on this table...
|
by: jaYPee |
last post by:
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very...
|
by: vvyshak |
last post by:
Hi all...
I have a table in which some columns has distinct values and some has
duplicates..i wan to select all the columns with distinct values....no
problem if rows has null value in it....i...
|
by: issac |
last post by:
Hi folks
Im trying to do a simple query involving the distinct keyword and an
access 2000 db, but have been frittering with it for amost and hour
and a half and I cant make it work.
This is...
|
by: kev |
last post by:
Hi all,
I have created a database for equipments. I have a form to register the
equipment meaning filling in all the particulars (ID, serial, type,
location etc). I have two buttons at the end...
|
by: LetMeDoIt |
last post by:
Greetings,
I'm using ASP to retrieve from MSSQL and I then populate a table.
After several months of successfull retrieves, this same code now
bombs out. It turns out that if I clear out from...
|
by: RussCRM |
last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
|
by: omnittha |
last post by:
I would like to pull unique records of a SINGLE column but not the other related columns. When I use DISTINCT, it pulls up all the records which are unique across the columns. Here is the code.......
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |