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 tried a lot wit distinct and
group by but nothing got worked out...
Waitin for your reply.....
Thanking you... 2 8645
Try the Having clause
For example, this will bring back records that have duplicate records
for Col1, Col2 and Col3.
If you want only records that have a single record, you can change ">
1" to "= 1".
SELECT DISTINCT
Col1, Col2, Col3, COUNT(*) as NumberDups
FROM SomeTable
GROUP BY Col1, Col2, Col3
HAVING COUNT(*) > 1
Of course, you could post your table definitions with Create statements
and insert statements so people could have data to work with to help
you. vv*****@gmail.c om wrote: 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 tried a lot wit distinct and group by but nothing got worked out... Waitin for your reply..... Thanking you...
(vv*****@gmail. com) writes: 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 tried a lot wit distinct and group by but nothing got worked out... Waitin for your reply.....
I will have to admit that I have a poor understanding of what you are
asking for. But there is a standard recommendation for this sort of
questions, and that is that you post:
o CREATE TABLE statements for your table(s).
o INSERT statements with sample data.
o The desired output, given the sample data.
o A short description of the underlying business problem.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dean |
last post by:
I want to build query to return how many rows are in this query:
select distinct c1, c2 from t1
But SQL won't accept this syntax:
select count (distinct c1, c2) from t1
Does someone know how to count multiple distinct columns? Thanks.
|
by: Jason L James |
last post by:
Hi all,
does anyone know if I can create a dataview
from multiple datatables. My dataset is constructed
from four separate tables and then the relationships
are added that link the tables together. To make
data entry easier I would like to combine selected
columns from the four tables onto a single dataview that
could be used as the...
|
by: Peter Proost |
last post by:
Hi group,
has anyone got any suggestions fot the best way to handle this problem, I've
got 3 tables
for example table A, B, and C
table A looks like name, value
table B looks like name, value
table C looks like variablename, value, value
an example would be
|
by: zaphod |
last post by:
I need to select unique combinations of 4 columns from one table and insert
them into a new table but I can't think of any way of finding unique
combinations of more than 1 column since SELECT DISTINCT only works on
single columns. Any ideas?
zaphod
|
by: p175 |
last post by:
Hi people,
I have a stored procedure that creates many Global temporary
session tables. Into each of these tables go the results of various
processing using relational division all keyed and based on a common ID
from an ID session table. So we can have various session tables with
differing results but if they contain records, they are all...
| |
by: MP |
last post by:
Hi
trying to begin to learn database using vb6, ado/adox, mdb format, sql
(not using access...just mdb format via ado)
i need to group the values of multiple fields
- get their possible variations(combination of fields),
- then act on each group in some way ...eg ProcessRs (oRs as RecordSet)...
the following query will get me the...
|
by: Michel Esber |
last post by:
Hello,
Db2 Linux LUW FP 15.
Consider table A (ID varchar, EXECUTION_DATE date).
a) I want to first retrieve all IDs that have not executed during the
last 90 days:
select distinct ID from table_B where NOT EXISTS
|
by: ukchat |
last post by:
I.m creating a dynamic query to pull out workbooks from my database the table structure is below.
Table: curricworkbooks
Columns: ID, curric, assessment, topic, workbook, filename
Example data
1 N1/E1.1 Numeracy E1 Count 1 workbooks/Num Entry 1/Unit 1/04 N1E1.1-3 Worksheets Num.pdf
10 MSS1/E1.6 Numeracy E1 Capacity...
|
by: omerbutt |
last post by:
hi there i have to select 7 columns from table1, 1 column from table2, and 1 column from tables3 and show the result but i am not getting it right the main thing that i am trying to achieve is that i am making a notice board in a community and i have to show the notices that are posted for the specific user by comparing the fields like GENDER AGE...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |