Spezial-SQLabfragen (Projekt: Instagramlocations), Stand: 14.07.2018

(1) Ausgabe der Usernames als Auflistung, mit Mindestanzahl in Bezug auf die Locations

SELECT username, numb from(
Select username, count(location) as numb from locations GROUP BY username ) as my_table
WHERE numb >= 2 order by numb DESC;

(2) Ausgabe der Usernames als Auflistung mit Mindestanzahl in Bezug auf die Locations UND Vorkommen eines Substrings in den Tagwolken

SELECT username, numb from(
Select username, tag, count(location) as numb from locations GROUP BY username ) as my_table
WHERE (numb >= 2) and (tag like '%fashion%') order by numb DESC;

(3) Ausgabe der Locations als Auflistung mit Mindestanzahl in Bezug auf die erfassten User_innen

SELECT location, Anz_user from(
Select location, count(username) as Anz_user from locations GROUP BY location ) as my_table
WHERE (Anz_user >= 2) order by Anz_user DESC

(4) Ausgabe der Locations als Auflistung mit Mindestanzahl in Bezug auf die erfassten User_innen UND Vorkommen eines Substrings in den Locations

SELECT location, Anz_user from(
Select location, count(username) as Anz_user from locations GROUP BY location ) as my_table
WHERE (Anz_user >= 2) AND (location like '%hotel%') order by Anz_user DESC;

(5) Ausgabe der Locations als Auflistung mit Mindestanzahl in Bezug auf die erfassten User_innen UND Vorkommen eines Substrings in den Locations UND Vorkommen eines Substrings in den Tagwolken

SELECT location, Anz_user from(
Select location, tag, count(username) as Anz_user from locations GROUP BY location ) as my_table
WHERE (Anz_user >= 2) AND (location like '%hotel%') AND (tag like '%fashion%') order by Anz_user DESC;

Schreibe einen Kommentar