+ 2

SELECT DISTINCT * FROM customers WHERE city = 'Newyork'; is it possible?? if there are multiple city then show only once.

9th Oct 2016, 6:53 AM
Morshed Islam
Morshed Islam - avatar
14 odpowiedzi
+ 9
"Distinct" doesn't use with "* (all)" character. You use one with concrete expression. See example in first part.
9th Oct 2016, 7:08 PM
Leonid D.
Leonid D. - avatar
+ 5
select distinct(column name) from <table name>; use this syntax. it will give you result
10th Oct 2016, 5:49 PM
sangamesh naikar
sangamesh naikar - avatar
+ 2
if you want to show newyork only then no need of distinct remove distinct and your query is correct
16th Oct 2016, 5:05 PM
Kunal Burangi
Kunal Burangi - avatar
+ 2
Not possible as the asterisk ( *) in SQL is used in selecting all while Distinct is specified
1st Nov 2016, 7:02 AM
Godson Allaputa
Godson Allaputa - avatar
+ 1
no it is not possible because already all columns & raws have been selected
22nd Nov 2016, 6:38 AM
Prince
+ 1
if u use "distinct" and "*" both together it through error. because we never use "distinct" and "*" both togather by this SQL also getting confuse, "*" return all the columns, and if u use "distinct" its only return only "distinct" column.
6th Dec 2016, 5:14 AM
Avyay Patel
Avyay Patel - avatar
0
thanks
10th Oct 2016, 4:03 AM
Morshed Islam
Morshed Islam - avatar
0
You could also just restrict your results using the TOP function. SELECT TOP 1 * FROM CUSTOMERS WHERE City = 'New York'; In this instance, the data is sorted by ID in ascending order. So, the first customer from New York would be the one provided in the results.
13th Oct 2016, 2:45 PM
Kevin Zufelt
0
not possible .. syntax error
15th Oct 2016, 5:59 PM
Ahmad Aldali
Ahmad Aldali - avatar
0
no not poossiblep
16th Oct 2016, 3:23 AM
Thinuwan Imihira
Thinuwan Imihira - avatar
0
there are multiple solutions for this SELECT * FROM Customers WHERE city='new York' limit 1; SELECT * FROM Customers WHERE city='new York' GROUP BY city; you can use LOWER(city)='new york'. which will make the value lower case before comparison. UPPER() is also available.
16th Oct 2016, 8:58 PM
Anand Pol
Anand Pol - avatar
0
not possible
18th Oct 2016, 11:01 PM
Zubair Khan
Zubair Khan - avatar
0
this syntax will work.. it's correct only but here v need to understand d concept that u r using distinct for all columns of customer table by using *. so u will get output with Newyork city name but it will check for all columns. I mean for example if in customer table one customer with delflg 0 and 1, 2 rows were der means this query will fetch both d data coz it's searching for distinct for all columns of customer table. hope this information is useful for you
16th Nov 2016, 6:27 AM
shivanagaraj
0
yes I is applicable for *
12th Feb 2017, 6:58 PM
manish
manish - avatar