Skip to content

Tag: sql

sql selecting unique rows based on a specific column

I have an table like this : I am trying to filter out something like this based on Col1 I am trying to get the all unique rows based on the values in Col1. If I have duplicates in Col1, the first row should be taken. I tried SELECT Col1 FROM tblname GROUP BY Col1 and got unique Col1 but

SQL table.column not working when I use it with full join

I have this SQL query: And it returns the error : “unknown column main.cname in filed list”. while the column certainly exists: seems alright. I tried using aliases but it just made it worse. I’m clueless Answer As coyeb60297 has pointed out, MySQL doesn’t do full outer joins so your q…

SQL DATEPART(qq, @date) date quarter start October

I have a query that prints the data grouped quarter, the query uses datepart(qq,repo.lesson_date) SQL function. My issue is I want my first quarter to be October-December and not Jan-March like the output I get from the SQL function above. Is there anyone can assist? Answer You may use an additional calculati…

SELECT from table with count from another

I have 2 mysql tables I need to get all views by user, but also need to get the user role (for each view) and calculate a dynamic number of users used for every view. So, I need to get all view columns, plus the role of the user which do this request (from ViewUser), plus count of users for

SQL Query for the player and vsplayer [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question Team Table Expected Output: with Two columns How to write a sql query to get the exact output …