Skip to content
Advertisement

Tag: tsql

How to display rows with no count aggregate result?

I have a table which contains Job, City and PersonName (who works in that city). I want to return all jobs and cities even if there is no one working in that city. This is a simple example : Creation of the table : My Query My result But I would like to have : I have no clue how

System Catalog vs Information Schema

When looking at SQL Server Management Studio (SSMS), which one is better and why? Are there cases where we should use one over the other? I can’t tell the difference between them. Answer INFORMATION_SCHEMA is there for compatibility, it doesn’t expose all the information about objects on the instance. sys however, fully exposes any relevant information, though you do need

Top 3 Values in the Same Row

I am working on Steam data and need to find the top 3 tags people used for each game but the problem is all the tag values are in the same row for each game like the image below (appid column then 370 column for each tag and values). Result can be anything like 200,300,400 or column name plus tag

How to select and join field with max date?

I have two tables joined on RECID and AAATRANSPORTORDERRECID : AAATRANSPORTTABLE AAALTLCHANGEREQUEST I need to select the record shown from AAATRANSPORTTABLE and join the AAALTLCHANGEVALUE value for the most recent CREATEDDATETIME from AAALTLCHANGEREQUEST. My query is as below: It produces these results: My desired output is Answer The problem is you are selecting max(l.CREATEDDATETIME) in your select query but you

Advertisement