I have a database which looks like this. My task is to get the columns of dates, number of exams on that date, number of students who write an exam on that date. Something like Date – Exam Count – Student Count. I have done this but in two different queries. Result: edate Exams | =================…
Tag: sql
Create SQL command with a query parameter that checks for NULL but also for other values
I am trying to write a dynamic SQL command using Python / Postgres. In my where clause I want to use a query parameter (which is user defined) that has to look for NULL values within a code column (varchar), but in other cases also for specific numbers. If I have to check for a certain value I use this:
FOR XML in SQL Server: Elements based on common values of columns
I’m using FOR XML to create an XML file out of SQL queries. I want to have elements based around common values for a particular column, in this case “location”: I can easily convert his into XML row-by-row like so: Which produces XML that looks liks this: But what I actually want is this: An…
How to aggregate and Join or Union into flat Json object with arrays?
I have data that looks like: Customers Table CustomerContacts Table Here’s the result I’m looking for: What I have tried: I’m embarrassed to say I’m not even close: Answer Unfortunately, SQL Server jumped on the JSON wagon a bit late in the game (started built in support only in 2016 v…
2 columns one below another in sql
I’m getting this error ORA-12704: character set mismatch can you please help me to fix this Answer See whether this helps. I presume that this is your situation: This is your current query: This is what you might try to do – apply the to_char function to a nvarchar2 column:
SQL entries in French/English and Japanese
I have an old SQL4 database and I’m trying to re-upload it to our newly created database on Phpmyadmin. The characters in the tables are latin and japanese. I tried to change those specific columns but the result is still broken characters for the columns I need to display in Japanese. Here is a screens…
peewee : how to filter data in a table based on values across rows in another table
Considering following peewee backed python code, how to filter data in a table based on values across rows in another table e.g. if I want to get a note in Note table having all java, lambda, generics tags in customtags I am really not having idea how to modify my code the get the data above mentioned, I know…
Are postgresql `SELECT DISTINCT` queries deterministic?
Are Postgres SELECT DISTINCT queries deterministic? Will SELECT DISTINCT somecolumn FROM sometable return the same result (including order) if the table (and entire database) goes unchanged? In the Select Query Documentation the Description section notes: If the ORDER BY clause is specified, the returned rows…
Replace subquery with join for the same table
Can the expected result in this case be accomplished without a subquery ? Maybe using a join ? We have a name say ‘jose’, Expected result is all rows which has same color as jose. Query should run in both MS-SQL and ORACLE. http://sqlfiddle.com/#!18/5f7e3/2 Answer You can get this result with a JO…
SQL extract only latest modified record AND correct days count IN 3 table join
This query needs to do 2 things it’s not doing at the moment: If a h.name is strictly equal to other h.name, it should only select the latest record (where the h.modify_at is the most recent). Currently it selects all “h”). The following line: (EXTRACT(epoch FROM (SELECT (NOW() – date_…