Skip to content
Advertisement

Tag: greatest-n-per-group

Select row with most recent date per user

I have a table (“lms_attendance”) of users’ check-in and out times that looks like this: I’m trying to create a view of this table that would output only the most recent record per user id, while giving me the “in” or “out” value, so something like: I’m pretty close so far, but I realized that views won’t accept subquerys, which

SQL query to find the highest paid salary for each lanauges

As I am not expert in writing the SQL queries so want for help. I have a table called programmer whose structure & data look like: In prof1 data are: PASCAL,CLIPPER,COBOL,CPP,COBOL,PASCAL,ASSEMBLY,PASCAL,BASIC,C,PASCAL,FOXPRO. In prof2 data are: BASIC,COBOL,DBASE,DBASE,ORACLE,DBASE,CLIPPER,C,DBASE,COBOL,ASSEMBLY,BASIC,C. In salary data are: 3200,2800,3000,2900,4500,2500,2800,3000,3200,2500,3600,3700,3500. I need a query to display the names of highest paid programmer for each language, which means I need

Select EMP with max SAL from each DEPT

I´m having a bad time with a SQL query. I´m using oracle default tables: ‘EMP’ TABLE http://imageshack.us/photo/my-images/850/sinttuloxps.png/ AND ‘DEPT’ TABLE http://imageshack.us/photo/my-images/19/assayp.png/ I wan´t to get the employee with the highest salary in each department. I´m using SQLPLUS. Thanks in advance! ALSO CODE: Answer Classic greatest-n-per-group query. Here is what you want: Here is a working fiddle: http://sqlfiddle.com/#!4/7147b/6 Additionally, you might

how to sort order of LEFT JOIN in SQL query?

OK I tried googling for an answer like crazy, but I couldn’t resolve this, so I hope someone will be able to help. Let’s say I have a table of users, very simple table: and I have another table of their cars and their prices. Now what I need to do is something like this (feel free to rewrite): Which

Advertisement