Skip to content

Tag: sql

Renumbering A Column Based On Other Columns

This table contains Purchase Orders which can have multiple lines per order. Right now the table appears like this. Purchase_OrderNumber Account_Number Line_Number 174558 0000448 1 174558 0000448 2 175812 295812 1 175812 295812 1 175812 295812 2 175812 295812 545 175812 295812 26686 175812 295812 53481 175813…

Finding orders placed between two times gives zero result

I’m not sure what’s happening here. I’m trying to select the orders that were placed between 4PM and 4AM, so from 1600 to 0400. The date does not matter, just the time. This is what I’ve tried so far. Here is the code for the table: I selected using several ways: I keep getting nothing…

How to find the desired output using hive/sql

I have a table like this col1 col2 First row Second a First b Second row First c Second row The output required is like below: col1 col2 col3 First row 1 Second a 1 First b 1 Second row 2 First c 2 Second row 3 The logic is , whenever we are getting the value “row” in col2,

Change td content according to database

I have two table for assignments. TABLE1 has the data of the assignments posted by a faculty and TABLE2 has data of those students who submitted the assignments. Both table have one similar column called ‘assignment name’. My TABLE2 has a status column which is boolean data. By default i have set …

SQL: Conditional mean based on groups

Suppose I have a data like this I want to calculate the average of VALUE by Group ID, but conditional on VALUE being smaller or equal than the median by group. So for instance, for Group 1, the median is 4 and 2,3,4 are smaller or equal than 4, so it should give for group 1: Does anyone have a

Complex mysql query counting

I have 1 table name “companies” with several datas like : Id Owner Company Job 1 John Doe Company 1 CEO 1 John Doe Company 2 CEO 1 John Doe Company 3 CEO 1 Gab Durand Company 4 CEO 1 Rob Dujn Company 5 CTO 1 Alex DoeMorse Company 6 COO What I need is to get 1 line by

pgsql merge two json arrays

I have to select two type of result set from a table and merge them in single json array like Its saying syntax error I believe due to order by. I need to return this in json array so I am trying like this Its retiring two json arrays i.e. obvious, How can I make this in single array Thanks,