Skip to content

Tag: sql

How can I compare rows of two similar tables in SQL?

These TSQL tables are exact but I can’t guarantee that. I cannot guarantee which rows will be non-existent in either table. What I want to be able to do is to subtract one from the other into a new table. For instance, “Agg Asslt” should have a column value for “OffenseCount” of …

Getting empty result from a query

I have Client table ClientGuid Email Phone Also have Activity table ActivityTitle Date ClientGuid If client does some “Activity” it is saved in Activity table. I want to get Emails of clients who did not have any activity in last three months and had activities before. Tried this : Getting empty r…

Postgresql – Looping through array_agg

I have a table from which I need to calculate the number of times intent_level changes for each id. Sample Table format : I couldn’t figure out how to loop through array_agg and compare consecutive elements. Below I tried using array_agg, but then I don’t know how to loop through it and compare co…

get most frequent values in every month in 2021

Trying to get the most frequent values in every month from tables inspection table : can be ignored – > FOREIGN key (lno) REFERENCES restaurant) data : query : output: month id 3 333 4 222 5 222 6 333 expected output – month id 3 333 4 222 5 111 6 222 6 333 Answer IMHO you don’t need

Categorizing the columns of one row in SQL

I have a database table with records like the picture: So each record contains columns related to points of the project lifecycle. I need to categorize those columns in order to know how many columns are ‘completed’ or ‘In Progress’ or ‘Not started’ I want the output to be …

select count with another select and inner join

Is it possible to use two “select” in the same query? I tried it but got the syntax error several times. My query example: I would like the result shown to be all queries on the screen. Basically, what I want is that the result shown when executing the query is the first and second “select&#…