I am being forced to use an ODBC source for SSRS report builder, source is Impala SQL, which doesn’t support the use of parameters. So I had to use a string builder function to get parameters into my script. This is working well, however the ask was to allow for multiple values in the text parameter. I …
Tag: sql
How to write a SQL to count total number of occurrences of value in column after group by while taking count as 1 if the group has the value?
I have a data with following structure As title suggests, I want to count occurrence of ‘FAIL’ in ColumnC after grouping by ColumnA, and ColumnB and while counting the occurrence, I want to count only one ‘FAIL’ in the group. For example, if I did the counting for the above example dat…
Getting row samples from PostgreSQL
I have a data table with timestamp and some data columns. The rows are inserted in arbitrary time intervals, i.e. the timestamp difference of consecutive rows is not stable but ranges from several seconds to several hours. I need to select one row per time interval of constant length, if there is any. Example…
Display all data which are between these dates
So currently, I am trying to display a list of items which are not between date X and date Y. Let us assume that book_date_start = 2021-06-15, and bookdate_end = 2021-06-20 This is my current query: So based on this So basically as I was writing the above out, I realized that my query is WRONG, and since 2021…
SQLite Insert Distinct from 2 variables
I have a SQLite DB with a table with the following kind of data: What I need to do is take columns B and C, create a single unduplicated list and autoincrement the primary key for the unique values. It needs to check to make sure an entry is not already existing – so the second table would be: I
Display group having certain value only on max date and not in other entries of group
I am looking to display the group which is grouped on id column where trans_cd=’Audit’ only on max trans_proc_dt of that group. There should not be any other trans_cd=’Audit’ execpt for max trans_proc_dt. My output should be I can’t think how to go about getting my result set. An…
How can I show values with zero in a Group By query
I am trying to get the zero values from my status table associated with the case of one user. So, I have this query that returns me only one value because, I have only one case associated with one status but I want to receive also the another status with value 0. So I have the status ‘Open’ and &#…
SQL Query creation with multiple joins
I am working with MYSQL, and want to create a query. I have 3 tables. QUESTION QUESTION_NUMBER QUESTION_DESCRIPTION 1 anydesc 2 anydesc2 ANSWER ANSWER_NUMBER ANSWER_DESCRIPTION 1 anydescANS 2 anydesc2ANS 3 anydesc3ANS And a bridge TABLE QUESTION_ANSWER Q_NUM A_NUM 1 1 2 2 2 3 Now I want to retrieve all the An…
SQL replace and insert Into
I have this table “NamesTable” in SQL Server. I want to insert and replace in a second column the corresponding name like this This is my query: The query runs and replace the selected words, but do not insert into my existing table. What I am doing wrong? Answer No idea what is the objective of y…
Bigquery replace value in a column based on previous year date condition
I need help to write a SQL logic in bigquery to replace a value in one column based on a condition as below FINANCIAL YEAR –> JUL to JUN How can I make it more dynamic so it rolls over next year Current: Version DATE ACT 202104 ACT 202101 ACT 202006 ACT 202001 ACT 202007 ACT 201903 ACT 202008 TAR