AgerNic.com/ro
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
Tutorial

SQL SELECT DISTINCT


<< Previous Page
sintaxa SQL
Next Page >>
sintaxa SQL

SQL Tutorial » SQL SELECT DISTINCT

Ce este select distinct în SQL?

Instruc?iunea SELECT DISTINCT este utilizat? pentru a returna numai valori distincte (diferite), sau mai bine spus: Cuvântul cheie DISTINCT în SQL este folosit pentru a prelua numai înregistr?ri unice dintr-un tabel al bazei de date. Este de obicei folosit împreun? cu instruc?iunea SELECT.

În interiorul unui tabel, o coloan? con?ine adesea multe valori duplicate; ?i uneori dori?i doar s? enumera?i diferitele valori (diferente).

Sintaxa SQL WHERE:

SELECT DISTINCT coloana1, coloana2, ... coloanaN
FROM nume_tabel;

In exemplul de mai jos avem un tabel „Clien?i” dintr-o baza de date precum "Test_clienti":

ID Prenume Nume Tara Oras Produs ID Cantitatea
1 Clark Kent USA Miami 24 11
2 Pire Joveau France Paris 56 32
3 Cristian Andone Romania Brasov 67 9
4 Pepe Martínez Spain Madrid 112 26
5 Peter Parker SUA Los Angeles 19 41

 

SELECT f?r? DISTINCT - Exemplu

Urm?toarea instruc?iune SQL selecteaz? toate (inclusiv duplicatele) valorile din coloana „Oras” tabelul „Clien?i”:

SELECT Oras FROM Clien?i;

Rezultatul: Num?r de înregistr?ri: 5

Oras
Miami
Paris
Brasov
Madrid
Los Angeles

 

Related subjects:
Sintaxa SQL Instructiunea Select Insert data into SQL Display data from SQL

 

Tags: sql select distinct on one column, sql select distinct multiple columns, count, multiple columns group by, values and count of each select distinct * from table
What is select distinct in SQL?
How do I select only unique rows in SQL?
How do I get unique values of a column in SQL?
What is difference between unique and distinct in SQL?

 

SELECT DISTINCT Prenume, Nume FROM Clienti Exemple

Urm?toarea interogare preia combina?ia unic? de valori Prenume ?i Nume.

SELECT DISTINCT Prenume, Nume FROM Clienti;

Rezultatul: Num?r de înregistr?ri: 5

Prenume Nume
Clark Kent
Pire Joveau
Cristian Andone
Pepe Martínez
Peter Parker

 

Urmatorul exemplu selecteaza doar tarile distincte din tabelul "Clienti".

SELECT count(DISTINCT Tara) FROM Employee;

Rezultatul: Num?r de înregistr?ri: 4

count(DISTINCT EmpId) 4

 

Clauza SELECT DISTINCT

Când lucra?i cu instruc?iunea SQL SELECT, mai mult ca sigur ve?i întâlni rânduri duplicat atunci când vizualiza?i rezultatele interog?rii. Acest lucru nu ar trebui s? cauzeze probleme reale ?i, folosind cuvântul cheie SQL DISTINCT în instruc?iunea SELECT, ve?i putea elimina toate rândurile duplicate din rezultatele interog?rii.

 

Acesta este un ghid pentru SQL SELECT DISTINCT. Aici discut?m despre Introducerea lui SELECT DISTINCT în SQL ?i despre exemplele practice ?i diferitele expresii de subinterogare.

 

Tags: sql select distinct on one column, sql select distinct multiple columns, count, multiple columns group by, values and count of each select distinct * from table
What is select distinct in SQL?
How do I select only unique rows in SQL?
How do I get unique values of a column in SQL?
What is difference between unique and distinct in SQL?


Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


analytics piwika