我的要求是從字符串中獲取第二個和第三個'/'之間的數據(/從右到左考慮)和下面是示例示例。 1.My string is RAM/ESH/BA/BU/MOR/SA and output to be derived is BU
2.My string is RAM/ESH/BA/MOR/SA and output to be derived is BA
3.My String is TR/IV/
下面我有此查詢: Select b.b_id as Business_id, b.business_name, Average_Rating, b.review_count AS Review_count
FROM (
SELECT b.b_id AS Business_id, AVG(r.rating) AS Average_Rating
FROM Business b
這裏是我的SQL小提琴:http://sqlfiddle.com/#!4/75ab7/2 基本上,我創建了一個表,並插入一些數據吧。 CREATE TABLE subject (
id INT NOT NULL,
seq_num INT NOT NULL,
name VARCHAR(30) NOT NULL
);
INSERT INTO subject
Student Name Subject Name Marks
Sam Maths 100
Tom Maths 80
Sam Physical Science 80
John Maths 75
Sam Life Science 70
John Life Science 100
John Physical Scien