学生姓名及其在计算机编程中的标记

时间:2019-04-18 14:50:49

标签: oracle

写一个查询以按“计算机编程”的顺序显示学生的姓名和他们的分数,然后按标记升序排列,然后按名称按降序排列。为标记命名为CP_MARKS。

我尝试过这个。

     select student_name, value from
        (select subject_id, student_id 
        from student s, subject su, mark m 
        where s.student_id=m.student_id 
        and su.subject_id=m.subject_id
        group by student_id
        order by student_id)
        where subject_name='Computer Programming'
        order by value;

这是架构: enter image description here

2 个答案:

答案 0 :(得分:0)

您需要通过使用适当的联接来联接表markstudentsubject
然后应用条件subject_name = 'Computer Programming',最后对结果进行排序:

select 
  st.student_name,
  m.value CP_MARKS
from mark m
inner join student st on st.student_id = m.student_id
inner join subject su on su.subject_id = m.subject_id
where su.subject_name = 'Computer Programming'
order by m.value, st.student_name desc

答案 1 :(得分:0)

@LayoutSpec
object CrgSpec {
    @OnCreateLayout
    fun onCreateLayout(
        c: ComponentContext,
        @Prop viewModel: ViewModel,
        @State fields: ArrayList<RadioItem>,
        @Prop parentId: String
    ): Component? {
        val row =
            Row.create(c)
                .alignItems(YogaAlign.CENTER)
                .alignContent(YogaAlign.SPACE_AROUND)
                .flexGrow(1F)
                .wrap(YogaWrap.WRAP)
        fields.forEach { item ->
            row.child(
                CRadio.create(c)
                    .value(item.text)
                    .clickHandler(Crg.onClicked(c, item.id, item.text))
                    .isChecked(item.isChecked)
                    .id(item.id)
                    .build()
            )
        }
        val column = Column.create(c)
            .paddingDip(YogaEdge.TOP, 20F)
            .child(row.build())
        return column.child(
            TextInput.create(c)
                //.visibleHandler()
                .backgroundRes(R.drawable.edit_text_bg)
                .build()
        ).build()
    }

    @OnCreateInitialState
    fun onCreateInitialState(
        c: ComponentContext?,
        fields: StateValue<ArrayList<RadioItem>>,
        @Prop initChecked: ArrayList<RadioItem>
    ) {
        fields.set(initChecked)
    }

    @OnUpdateState
    fun updateCheckboxState(
        fields: StateValue<ArrayList<RadioItem>>,
        @Param id: String
    ) {
        fields.get()?.let { radioItem ->
            radioItem.forEach {
                it.isChecked = it.id == id
            }
            fields.set(radioItem)
        }
    }


    @OnUpdateState
    fun updateCheckbox(
        fields: StateValue<ArrayList<RadioItem>>,
        @Param id: String
    ) {
        fields.get()?.let { radioItem ->
            radioItem.forEach {
                it.isChecked = it.id == id
            }
            fields.set(radioItem)
        }
    }

    @OnEvent(ClickEvent::class)
    fun onClicked(
        c: ComponentContext?,
        @Prop viewModel: ViewModel,
        @Param id: String,
        @Prop parentId: String,
        @Param itemValue: String
    ) {
        Timber.d("id is: $id")
        CirclesRadioGroup.updateCheckbox(c, id)
        viewModel.onRadioUpdate(
            id,
            parentId,
            itemValue
        )
    }
}