I am still trying to finish fixing my details page and I need one more piece to fix it. I start with this query. NOTE:recordID actually comes in from the previous page by clicking an item. Also, name, img, item_code, and type_id are fields in my table not outside sources. Now, I have created this to determine…
SQL – get distinct values and its frequency count of occurring in a group
I have a table data as: The data set is as follows: I need to list all distinct search_product_result values and count frequencies of these values occurring in s_product_id. Required Output result-set: Here, A occurs in three s_product_id : 0, 1, 2, B in two : 0, 2, and so on. D occurred twice in the same gro…
How to convert a query into a nested query
How do I change this query into a nested query? The query and tables are listed below. tables goes as follows Nation : N_NATIONKEY, N_NAME Supplier : S_SUPPKEY, S_NAME, S_NATIONKEY Customer : C_CUSTKEY, C_NAME, C_NATIONKEY Orders: O_ORDERKEY, O_CUSTKEY Lineitem: L_ORDERKEY, L_SUPPKEY, L_QUANTITY, L_EXTENDEDPR…
MySQL select count from different columns using also group by
I have this table called tasks. I want to fetch count of the total task of each assign_date and on that date how many complete task by complete_date per user. I want something like below [{ …
optimization select distinct query
How can i optimize this query, how to rewrite a request through exists: Answer Please use ANSI style join syntax, first of all. Now, Coming to your question, according to my knowledge NVL perform worse when working with large data sets. So how can we achieve the same functionality? — We can use DECODE o…
I have problem to use like and where clause together in sql
I want to select data from the SQL table and fetch data from the table with the use of LIKE and BETWEEN clause together and I have tried below query. but it shows me the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
Need to create a Totals report from oracle table data
I have a table in oracle similar to the the example table image that I need to have output the segregated totals as shown in the second example results image. I need the sums of each item_type where A & B are just examples for a large number of possible items that can be added. example table: example resu…
Weird behavior with MySQL GroupBy on multiple columns
I am writing a query that groups a table of users by (height, sex) and then gets the name of the user with the minimum weight for that combination of height and sex. If you wanna skip to the actual query, here is the SQLFiddle with a minimal representative example. If you don’t want to open that url, he…
How to print the cursor values in oracle?
I am new to oracle and I am learning cursors.My table City has two columns city_id,city_name.So,this is what I tried: i am trying to assign the data of cursor to the newly declared value v_list SYS_REFCURSOR;.But the output is coming as error at v_list := city_list;.How can I assign all the values of cursors …
How to group records by hours considering start date and end date
I’m trying to group records by hours with consideration of duration. Assume there are long running processes and there is log data when process has been started and finished. I’m trying to get report by hours how many processes were running The data looks like this Process_name Start End ‘A&…