Write a query to display the book code, book title ,supplier name and price of the book which takes maximum price based
Tag : mysql , By : Sinisa Ruzin
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Write a query to display the book code, book title ,supplier name and price of the book which takes maximum price based on each supplier. , The first step is to get the maximum price per supplier: SELECT supplier_id, MAX(Price) AS Price
FROM lms_book_details
GROUP BY supplier_id
SELECT bd.book_code,
bd.book_title,
sd.supplier_name,
bd.price
FROM lms_book_details AS bd
JOIN lms_suppliers_details AS sd
ON sd.supplier_id = bd.supplier_id;
SELECT bd.book_code,
bd.book_title,
sd.supplier_name,
bd.price
FROM lms_book_details AS bd
JOIN lms_suppliers_details AS sd
ON sd.supplier_id = bd.supplier_id
JOIN
( SELECT supplier_id, MAX(Price) AS Price
FROM lms_book_details
GROUP BY supplier_id
) AS MaxPrice
ON MaxPrice.supplier_id = bd.supplier_id
AND MaxPrice.Price = bd.Price;
BOOK_CODE BOOK_TITLE SUPPLIER_NAME PRICE
BL0000002 Java The compete reference ROSE BOOK STORE 750
BL0000006 Java The compete reference ROSE BOOK STORE 750
BL0000004 Java The compete reference SINGAPORE SHOPPEE 750
BL0000009 Fire KAVARI STORE 999
|
I need to find the book code and book title for each book found in branch number 2 and written by author 20
Date : March 29 2020, 07:55 AM
this one helps. want to find the book code and book title for each book found in branch number 2 and written by author 20. , You can use simple join between the tables. SELECT B.BOOK_CODE, B.TITLE
FROM BOOK B
JOIN WROTE W
ON W.BOOK_CODE = B.BOOK_CODE
AND W.AUTHOR_NUM ='20'
JOIN INVENTORY I
on I.BOOK_CODE = B.BOOK_CODE
AND I.BRANCH_NUM ='2'
|
I'm making a multiple choice quiz and can't figure out how to use loop to get Murillo answers from user before program e
Tag : python , By : Amit Battan
Date : March 29 2020, 07:55 AM
With these it helps More detail: program gives 3 answers and user has to pick one answer either you get it right and move on or wrong and you have to choose again. That's what I'm looking for after guessing/choosing wrong I wanna be able to choose again without program ending or giving me an error? , This might help you while(True):
print "Enter Choice"
print "1).Correct"
print "2).Incorrect"
print "3).Incorrect"
choice = raw_input()
if(choice == '1'):
print "That's Correct"
break
else:
print "Please Try Again"
|
Cant figure how to assign proper values of answers from a List<String> at a multiple choice quiz at flutter,
Tag : dart , By : user143038
Date : March 29 2020, 07:55 AM
around this issue At listAnswers[1] i did try to assign the string 'white' at the text view but it crashes my program, anyone have any idea why, here is the Class questions which contains a string question, list with answers and a string with correct answer to evaluate, and a quiz class to build the quiz. , Try this. import 'package:flutter/material.dart';
void main() => runApp(new MaterialApp(
home: new MainPage(),
debugShowCheckedModeBanner: false,
));
class MainPage extends StatefulWidget {
@override
_MainPageState createState() => new _MainPageState();
}
class _MainPageState extends State<MainPage> {
Questions currentQuestion;
Quiz quiz = new Quiz([
new Questions(
"Color of the snow is ", ["yellow", "white", "grey"], "white"),
]);
String questionText;
int questionNumber;
String isCorrect;
List<String> listAnswers;
@override
void initState() {
super.initState();
currentQuestion = quiz.nextQuestion;
questionText = currentQuestion.question;
questionNumber = quiz.questionNumber;
listAnswers = quiz.answers;
isCorrect = quiz.correctAnswer;
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Quiz'),
),
body: new InkWell(
child: Center(
child: new Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: new Text(
questionText,
maxLines: questionNumber,
style: new TextStyle(fontSize: 20.0),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: buildAnswerButtons(0),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new Text(
quiz._questions[0].correctAnswer,
style: new TextStyle(fontSize: 20.0),
),
),
],
),
),
),
);
}
Widget buildAnswerButtons(int questionPos) {
List<Widget> buttons = [];
for (String answer in quiz._questions[questionPos].answers) {
buttons.add(
new RaisedButton(
child: new Text(answer),
onPressed: () {},
),
);
}
return new Row(
mainAxisSize: MainAxisSize.min,
children: buttons,
);
}
}
class Quiz {
List<Questions> _questions;
int _currentQuestionIndex = -1;
int _point = 0;
List<String> _answers;
String _correctAnswer;
Quiz(this._questions) {
_questions.shuffle();
}
List<Questions> get questions => _questions;
List get answers => _answers;
String get correctAnswer => _correctAnswer;
int get length => _questions.length;
int get questionNumber => _currentQuestionIndex + 1;
int get point => _point;
Questions get nextQuestion {
_currentQuestionIndex++;
if (_currentQuestionIndex >= length) return null;
return _questions[_currentQuestionIndex];
}
}
class Questions {
final String question;
final List<String> answers;
final String correctAnswer;
Questions(this.question, this.answers, this.correctAnswer);
}
|
Trying to figure out code snippet in the book Eloquent JavaScript
Date : March 29 2020, 07:55 AM
like below fixes the issue In the first line, you're declaring a variable result. However, it's being declared with let, not var. Let is similar to var, except it can't be accessed outside the block it is defined in (including functions, loops and conditional statements). And since it's in a function here, that first line is equivalent to: var result = 1;
for (let count = 0; count < exponent; count++) {}
result *= base;
result = result * base;
return result;
console.log(power(2, 10));
|