+ 2
SELECT DISTINCT * FROM customers WHERE city = 'Newyork'; is it possible?? if there are multiple city then show only once.
14 odpowiedzi
+ 9
"Distinct" doesn't use with "* (all)" character. You use one with concrete expression. See example in first part.
+ 5
select distinct(column name) from <table name>;
use this syntax. it will give you result
+ 2
if you want to show newyork only then no need of distinct remove distinct and your query is correct
+ 2
Not possible as the asterisk ( *) in SQL is used in selecting all while Distinct is specified
+ 1
no it is not possible because already all columns & raws have been selected
+ 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.
0
thanks
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.
0
not possible .. syntax error
0
no not poossiblep
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.
0
not possible
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
0
yes I is applicable for *