Skip to content

Laravel Eloquent Join Using Another table

Hi how to convert this SQL query to Laravel Eloquent? I have three table: payments, devices and users. Payments table does not store user_id. but table has device_id. And device table also has user_id. I want to get user name which made payment. Answer it’s very easy Another way is: We have three models…

.js + sql variables cant get the sum

It just gives the two variables put together instead of the sum of the two Ex. 1 + 2 = 12 instead of 1 + 2 = 3 or args[1] + money = args[1]money instead of new value const { RichEmbed } = require(‘…

I want top ten supplier on basis of balance

I am writing a query using rank function and want top 10 suppliers on the basis of their balance. Below is the query which is i am using. SELECT VENDOR_NAME, Balance, RANK_MAX FROM (SELECT xsl….

How do I subquery within a case statement?

So here’s my coding select item_number[Item Number], SUM(CASE WHEN [type] = 0 and location_id not in (select location_id from t_location with(nolock) where location_id like ‘GW%’ or …

Oracle Database Query to be solved

create table employee (emp_id integer not null, manager_id integer not null, emp_name char(20) not null, emp_tel char(10), emp_salary number not …

Find average SQL statement multiple tables

Trying to get the average with a amount of times a user has purchases brocolli and then with the price at that time. A 0 if the user has not purchased any. This is working and saying it can’t see the Name column. What am I missing? EDIT I also tried simplifying to just use the purchasers table and get

Character with Bit/hex confusion in DB2

This works: SELECT TASKT_ID FROM DATA . TASKT WHERE TASK_WEB_IDENTIFIER = CAST ( HEXTORAW ( ‘0213725501A421D384233E5001’ ) AS CHAR ( 26 ) ) ; Since that work I put it into the procedure: BEGIN …